Farming didn’t just revolutionize human society—it transformed the genome of our oldest friend, the dog. A new study reveals that by 7000 years ago, our canine companions were eating so much wheat and millet they made extra copies of starch-digesting genes to help them cope. And this adaptation is what allowed them to stay by our sides, even as our world changed.

The genetic evolution in dogs parallels what others have found in humans, says Peter Savolainen, an evolutionary geneticist at the Royal Institute of Technology in Stockholm, who was not involved with the work. "With farming we started to eat starch, and both we and dogs had to adapt to this change."

Some of the first insights into how farming changed the canine genome came 3 years ago. That’s when evolutionary geneticist Erik Axelsson of Uppsala University in Sweden and his colleagues discovered that dogs have four to 30 copies of a gene—Amy2B—that helps digest starch, whereas wolves typically only have two. Morgane Ollivier wanted to know just when that genetic change happened. A paleogeneticist at Ecole Normale Supéieure de Lyon in France, she teamed up with Axelsson and others, who extracted ancient DNA from the bones and teeth of 13 wolf and dog specimens collected from archaeological sites throughout Eurasia. Four of the ancient dogs—from a 7000-year-old site in Romania and 5000-year-old sites in Turkmenistan and France—had more than eight copies of Amy2B, Ollivier and her colleagues report today in Royal Society Open Science . They do not yet know how many copies ancient wolves had.

Because these samples predate the emergence of dog breeds, believed to be within the past couple of centuries, the findings rule out a modern origin for the increase in copy number, says Laurent Frantz, an evolutionary geneticist at the University of Oxford in the United Kingdom who was not involved with the work. Adds Ollivier: "This [expansion] probably constituted an important advantage for dogs feeding on human leftovers,” as they hung around human settlements, perhaps serving as guard dogs.

Dogs were likely domesticated more than 15,000 years ago, and as companions to hunter-gatherers, were likely eating mostly meat. Being able to survive on whatever humans discarded likely enabled dogs to become widespread as people migrated across the globe, says Robert Wayne, an evolutionary biologist at the University of California, Los Angeles, who was not involved with the study.

In humans, the number of copies of this starch gene increased just as it did in dogs during the same time period, Ollivier says. She suggests there may be similar parallels in the evolution of metabolism, immunity, and brain processes in both species.

A 2016 survey of various types of dogs from around the world—as well as golden jackals, coyotes, and wolves—supports the new work. It found that almost all the wolves, jackals, and coyotes had just two copies of Amy2B. So did Siberian huskies and dingoes, both of which lived with people who, until recently, hunted or fished for most of their food. The rest of the dogs studied had many more copies of the gene. Farming led to a fivefold increase in the number of starch-digesting genes in these dogs, Axelsson, Savolainen, and their colleagues reported in July in Heredity .

Together, says Savolainen, the two studies "give a coherent picture" of man’s influence on man’s oldest friend.

*Correction, 9 November, 11:26 a.m.: This story has been modified to reflect the correct gender of Ollivier and the correct terminology for the starch gene.