Scientists at Uppsala University said genetic studies suggest dogs evolved from wolves that were able to scavenge and digest the food waste of early farmers.
Three genes found in dogs that are not present in wolves are vital for digestion and could have extended their ancestral carnivorous diet to include starch, the researchers wrote in the journal Nature.
Genes for the enzyme that splits starch into simpler sugars has replicated itself in the dog genome, and become more efficient, a sure sign that it is in demand, they said.
The emergence of these genes may have coincided with the dawn of agriculture, as human settlements began to create heaps of starchy waste, the researchers said.
"Wolves were probably attracted, but only the ones that evolved the ability to digest the starch waste kept coming back," researcher Erik Axelsson said.
"This ... hypothesis says that when we settled down, and in conjunction with the development of agriculture, we produced waste dumps around our settlements; and suddenly there was this new food resource, a new niche, for wolves to make use of, and the wolf that was best able to make use of it became the ancestor of the dog," he said.