Actually the dog is much more related to the wolf than humans are to the apes; dogs can interbreed with a wolf and produce viable offspring...indicating they are of the same species...humans cannot interbreed with apes.
Russian studies with foxes seem to prove that there is a genetic basis for "domesticity" involving canines. They selected the foxes for their gentleness an gregariousness and were able to produce a fox that was much like a dog, in that it was gentle and adapted to humans much like a dog...but it must be bred into them, it was not an acquired characteristic. This must have occurred early on when the wolves took up with mankind; the article suggests that it was at a hunting-gathering stage of our cultural evolution when a nomadic lifestyle was more conducive to the wolves' natural characteristics. Like you, I suspect that the "domestication" took place multiple times, in many places, in many groups over thousands of years.