While genetic similarities may help to explain why humans tend to gravitate together, the full story of why people become friends "is contingent upon the social environment in which individuals interact with one another," the researchers reported in the Proceedings of the National Academy of Sciences.
People are more likely to befriend genetically similar people when their environment is stratified -- when disparate groups are discouraged from interacting -- but when environments were more egalitarian friends are less likely to share certain genes, the researchers said.
They focused on 1,503 pairs of friends in seventh through 12th grade in 41 schools.
In a socially stratified school, "Students from different populations within the school may be effectively 'off limits' for friendships," the researchers wrote.
In the most socially equal environments, however, genetic homophily (or "love of the same") was "pretty weak," meaning that friends were less likely to share genetic traits, they found.
Scientists have long debated the extent to which genetics or environmental factors -- "nature" or "nurture" -- predict certain behaviors, sociology Professor Jason Boardman said.
It's usually not a matter of completely one or the other, he said.
"For all the social demographic outcomes we care about, whether it's fertility, marriage, migration, health, it's never nature or nurture.
"It's always nature and nurture," he said.