Image copyright Getty Images

Dogs most probably evolved from wolves at a single location about 20,000 to 40,000 years ago, a study suggests.

Previously, it had been thought that dogs were tamed from two populations of wolves living thousands of miles apart.

Researchers studied DNA from three dogs found at archaeological sites in Germany and Ireland that were between 4,700 and 7,000 years old.

The ancient canines share ancestry with modern European dogs.

By looking at the rates of change to the DNA from the oldest specimen, scientists were able to place the timing of the domestication of dogs to between 20,000 and 40,000 years ago.

Krishna Veeramah of Stony Brook University in New York is a researcher on the study.

He said the process of dog domestication began when a population of wolves moved to the outskirts of hunter-gatherer camps to scavenge for leftovers.

''Those wolves that were tamer and less aggressive would have been more successful at this," he explained.

"While the humans did not initially gain any kind of benefit from this process, over time they would have developed some kind of symbiotic relationship with these animals, eventually evolving into the dogs we see today.''

Image copyright Amelie Scheu Image caption DNA was obtained from the skull of an ancient dog

The story of how dogs came to be tamed from wolves is complex and hotly debated.

Scientists believe dogs started moving around the world, perhaps with their human companions, about 20,000 years ago.

By 7,000 years ago, they were pretty much everywhere, although they were not the kind of dogs that we would consider pets.

''They would likely have resembled dogs we today call village dogs, which are free-breeding that did not live in specific people's houses and have a similar look to them across the world," said Dr Veeramah.

The dogs were later bred for their skills as hunters, herders or gundogs, eventually creating hundreds of modern breeds.

The research, published in Nature Communications, suggests even the dog breeds and village dogs found in the Americas and Pacific Islands are almost completely derived from recent European dog stock.

This is probably due to prolific dog breeding in Victorian times.

Image copyright Timo Seregely Image caption The dog skull inside an ancient burial chamber

''In this regard, it appears therefore that our 7,000-year, Neolithic-old dog from Europe is virtually an ancestor to most modern breed dogs found throughout the world,'' said Dr Veeramah.

''This ancestral relationship may even stretch back to the oldest dog fossil we know of, which is approximately 14,000 years old from Germany.''

Previous evidence suggested that the first domestic dogs appeared on opposite sides of the Eurasian continent more than 12,000 years ago.

Later, the eastern dogs moved with migrating humans and bred with those from the west, according to this theory.

Dr Greger Larson of the University of Oxford said it was great to see more ancient dog genomes being published.

"There is a fascinating story here and we're only just scraping the surface," he said.

"The more we get the more we might have a shot at finally unravelling the story of how we became such good friends over such a long time."

Follow Helen on Twitter.