Humans and dogs have shared a long and beautiful relationship, but the story of how we got together has been lost to the sands of time - so we don't know exactly how long we've been friends.

According to new research, though, we started dogs on the path of domestication well before 11,000 years ago. By carefully sequencing the DNA of ancient dogs, researchers found that there were already at least five distinct genetic lineages at the end of the last ice age.

They also sequenced contemporaneous human DNA to trace the relationship between our two species over the millennia.

It was these early lineages, the researchers say, that were the basis for the many different dogs we know and love today.

"If we look back more than four or five thousand years ago, we can see that Europe was a very diverse place when it came to dogs," said geneticist Anders Bergström of the Francis Crick Institute in the UK.

"Although the European dogs we see today come in such an extraordinary array of shapes and forms, genetically they derive from only a very narrow subset of the diversity that used to exist."

We know that all domestic dogs (Canis familiaris) are descended from a wolf ancestor shared with today's grey wolf (Canis lupus). But precisely when that divergence occurred has been a matter of some debate. Some claim domestication - the process of slowly breeding wolves to select for more friendly traits - began over 100,000 years ago, although that interpretation is controversial.

It's generally accepted that dog domestication began sometime between 40,000 and 20,000 years ago. And it's possible that the process began with the wolves themselves self-domesticating as they grew attached to human settlements.

It's difficult to tell early dog fossils apart from ancient wolf fossils, and this new work makes no claims as to when or how canine domestication began - so it's not going to resolve any whats or wherefores about how it all kicked off.

But it does reveal fascinating new information about the shared history of humans and dogs.

The ancient dog DNA was sourced from 32 different animals, from 100 to 10,900 years old, from Siberia, Europe and the Near East. Five of those dog genomes had been previously sequenced; the team sequenced 27 new genomes for the most complete ancient dog DNA study yet. These were compared to a selection of modern dog genomes from around the world.

This is how the team found there were at least five distinct dog lineages as early as 11,000 years ago - they describe these as Neolithic Levant, Mesolithic Karelia, Mesolithic Baikal, ancient America, and New Guinea singing dog. So the domestication process had to have started long before that point. And traces of those lineages can be found in today's dogs.

dogs ancient(Bergström et al., Science, 2020)

Tibetan mastiffs, for example, have a strong mix of Bronze Age steppe and New Guinea singing dog lineages. Chihuahuas and Xoloitzcuintli have traces of the ancient America lineage. Basenjis have a strong contribution from the Neolithic Levant lineage. And New Guinea singing dogs can still be found in the wild today.

Interestingly, there didn't seem to be a back-and-forth gene flow between dogs and wolves. Previous research suggested that, as the two species were diverging, they continued to interbreed, contributing to early dog diversity. They did, in fact, continue to interbreed, but the gene flow seemed to go predominantly in one direction - from dogs to wolves.

Wolf-dog hybrids do exist today, which could be a clue as to this unidirectional gene flow: These hybrids are unpredictable and often wild, poorly suited to living with humans.

To reconstruct the relationship between dogs and humans over history, the researchers also compared the ancient dog DNA to the genomes of 17 humans living in the same places at the same times as the dogs.

In many cases, similar shifts occurred in the DNA of the dogs and the humans. These, the researchers concluded, likely reflected lifestyle changes, such as moving from one place to another. This makes sense: when humans migrated, they brought along their canine BFFs. That would explain why, for example, dogs from the Middle East and humans from the Middle East ended up in Europe at the same time.

But these changes did not always align. Sometimes the human population changed, but the dogs didn't. This suggests that dogs could move between human groups, or could have been valuable trade commodities. Why these differences exist is still a mystery, and may take a lot more ancient dog DNA to figure out.

One thing is very clear, though: Dogs and humans have found each other pretty awesome for a very long time now.

"Dogs are our oldest and closest animal partner," said palaeogeneticist Greger Larson of the University of Oxford in the UK.

"Using DNA from ancient dogs is showing us just how far back our shared history goes and will ultimately help us understand when and where this deep relationship began."

The research has been published in Science.