Being friendly is in dogs' nature and could be key to how they came to share our lives, say US scientists.
Dogs evolved from wolves tens of thousands of years ago.
During this time, certain genes that make dogs particularly gregarious have been selected for, according to research.
This may give dogs their distinctive personalities, including a craving for human company.
"Our finding of genetic variation in both dogs and wolves provides a possible insight into animal personality, and may even suggest similar genes may have roles in other domestic species (maybe cats even)," said Dr Bridgett vonHoldt of Princeton University.
The researchers studied the behaviour of domestic dogs, and grey wolves living in captivity. They carried out a number of tests of the animals' skills at problem-solving and sociability.
These showed that wolves were as good as dogs at solving problems, such as retrieving pieces of sausage from a plastic lunchbox.
Dogs, however, were much more friendly. They spent more time greeting human strangers and gazing at them, while wolves were somewhat aloof.
DNA tests found a link between certain genetic changes and behaviours such as attentiveness to strangers or picking up on social cues.
Similar changes in humans are associated with a rare genetic syndrome, where people are highly sociable.
Dr Elaine Ostrander of the National Institutes of Health, who was a co-researcher on the study, said the information would be useful in studying human disease.
"This exciting observation highlights the utility of the dog as a genetic system informative for studies of human disease, as it shows how minor variants in critical genes in dogs result in major syndromic effects in humans," she said.
Dogs were domesticated from wolves between 20,000 and 40,000 years ago.
This process began when wolves that were tolerant of humans sneaked into hunter gatherer camps to feed on food scraps.
Over the course of history, wolves were eventually tamed and became the dogs we know today, which come in all shapes and sizes.
The finding of genetic changes linked to sociability in dogs shows how their friendly behaviour might have evolved.
"This could easily play into the story then of how these wolves leave descendants that are also 'friendlier' than others, setting the path for domestication," said Dr vonHoldt.
The research is published in the journal, Science Advances.
Follow Helen on Twitter.