Sociality is believed to have evolved as a strategy for animals to cope with their environments. Yet the genetic basis of sociality remains unclear. Here we provide evidence that social network tendencies are heritable in a gregarious primate. The tendency for rhesus macaques, Macaca mulatta, to be tied affiliatively to others via connections mediated by their social partners - analogous to friends of friends in people - demonstrated additive genetic variance. Affiliative tendencies were predicted by genetic variation at two loci involved in serotonergic signalling, although this result did not withstand correction for multiple tests. Aggressive tendencies were also heritable and were related to reproductive output, a fitness proxy. Our findings suggest that, like humans, the skills and temperaments that shape the formation of multi-agent relationships have a genetic basis in nonhuman primates, and, as such, begin to fill the gaps in our understanding of the genetic basis of sociality.