Chinese farmers may have domesticated cats more than 5,000 years ago to protect their grain stores from rodents, a study suggests.
The animals would have carried out a similar function to the cat that caught the rat in the nursery rhyme This Is The House That Jack Built, written millennia later.
Scientists traced evidence of a close relationship between human and cat in the ancient village of Quanhucin, Shaanxi province, where millet cultivation was widespread.
Analysis of bones from at least two cats uncovered at the site showed that they preyed on grain-eating animals, probably rodents.
One of the cats had survived to an old age living in the village, while another had a diet suggesting it had scavenged human food or been fed.
At the same time, remains of an ancient rodent burrow into a grain storage pit, and the rodent-proof design of grain pots, indicated that rats and mice posed a serious problem for Quanhucin farmers.
"At least three different lines of scientific inquiry allow us to tell a story about cat domestication that is reminiscent of the old 'house that Jack built' nursery rhyme," said Professor Fiona Marshall from the University of Washington at St. Louis, US.
"Our data suggest that cats were attracted to ancient farming villages by small animals, such as rodents that were living on the grain that the farmers grew, ate and stored.
"Results of this study show that the village of Quanhucun was a source of food for the cats 5,300 years ago, and the relationship between humans and cats was commensal, or advantageous for the cats.
"Even if these cats were not yet domesticated, our evidence confirms that they lived in close proximity to farmers, and that the relationship had mutual benefits."
Cats have lived alongside humans for a very long time, but when and where they were tamed remains a mystery.
Previous evidence suggested they were first domesticated in ancient Egypt, where they were kept some 4,000 years ago.
More recent findings point to a much earlier association with humans, including the discovery of a wild cat buried with a human nearly 10,000 years ago in Cyprus.
Most of the estimated 600 million domestic cats now living around the world are known to be descended most directly from the Near Eastern Wildcat, one of five wildcat sub-species still found in the Old World.
The origins of the Quanhucin cats remain unknown, but there is no DNA evidence so far linking them to the Near Eastern Wildcat, and the species is not native to the area.
If the cats do turn out to be descendants of the Near Eastern strain it would indicate they were domesticated elsewhere and later introduced to the region.
"We do not yet know whether these cats came to China from the Near East, whether they interbred with Chinese wild-cat species, or even whether cats from China played a previously unsuspected role in domestication," Prof Marshall added.
The research is published online in the journal Proceedings Of The National Academy of Sciences.