The domestication of the dog was the process which led to the domestic dog. This included the dog's genetic divergence from the wolf, its domestication, and the emergence of the first dogs. Genetic studies suggest that all ancient and modern dogs share a common ancestry, descending from an ancient, now-extinct wolf population – or closely related wolf populations – which was distinct from the modern wolf lineage. The dog's similarity to the grey wolf is the result of substantial dog-into-wolf gene flow, with the modern grey wolf being the dog's nearest living relative. An extinct Late Pleistocene wolf may have been the ancestor of the dog.
The dog is a wolf-like canid. The genetic divergence between the dog's ancestor and modern wolves occurred between 20,000 and 40,000 years ago, just before or during the Last Glacial Maximum (20,000–27,000 years ago). This timespan represents the upper time-limit for the commencement of domestication because it is the time of divergence but not the time of domestication, which occurred later.