Riders and dogs. Ancient Greek Attic black-figure hydria, ca. 510-500 BC
So how were dogs domesticated? The scientific community largely supports what some call the self-domestication theory, in which wolves took advantage of the waste materials being produced from newly forming human civilizations. This implies that the earliest stages of domestication of the dog were probably unintentional and rather involved a significant natural selection component. Natural selection was observed in both behavioral and physical traits.
From a behavioral standpoint, less timid animals would stay at the human civilizations and feed longer, which led to enhanced survival and a gradual increase in the frequency of non-timid behaviors in the population. Also these animals were no longer relying on the pack to survive, so the strict social hierarchies began to relax.
Physical changes reflected a food source that was lower quality than prey (being less energy dense), and so natural selection would favor those animals with smaller body size, and a less robust dentition. And so there developed a new population of animal with these specialized adaptations to live in close proximity to humans.