Dogs were part of a key moment in human history - when our ancestors began trying their hand at farming.

As the first farmers moved out of the Middle East, herding animals such as sheep and goats, dogs tagged along too, say scientists.

The DNA evidence fills in some of the gaps in the story of how wolves became the dogs of all shapes and sizes that we know today.

Farming began in what is known as the Fertile Crescent of the Middle East.

This includes parts of modern-day Iraq, Syria, Lebanon, Jordan, Israel and Egypt.

Humans who were living as hunter-gatherers settled down and started growing wild varieties of crops like wheat, barley, peas and lentils.

They also domesticated animals from wild sheep, cows and pigs. About 9,000 years ago, they moved into Europe and Asia, taking their animals and farming know-how with them.

The new study shows their dogs also went on the trip.

The evidence comes from DNA extracted from canine remains found at archaeological sites across Europe and Asia.

"Our study shows that dogs and humans have an intertwined story - dogs followed humans during this migration across Europe," said Dr Morgane Ollivier of the University of Rennes in France.

"We show in this paper that dogs and humans were already really connected."

When the dogs arrived in Europe, they mixed with the dogs that were already there, changing the gene pool.

Centuries of dog breeding have mixed up the genes of dogs further. Modern dogs, of all shapes and sizes, are very different now to those early farm dogs who accompanied their owners on their travels.

The research is published in the journal Biology Letters.