The organization and coordination of fish schools provide a valuable model to investigate the genetic architecture of affiliative behaviours and dissect the mechanisms underlying social behaviours and personalities. Here we used replicate guppy selection lines that vary in schooling propensity and combine quantitative genetics with genomic and transcriptomic analyses to investigate the genetic basis of sociability phenotypes. We show that consistent with findings in collective motion patterns, experimental evolution of schooling propensity increased the sociability of female, but not male, guppies when swimming with unfamiliar conspecifics. This finding highlights a relevant link between coordinated motion and sociability for species forming fission–fusion societies in which both group size and the type of social interactions are dynamic across space and time. We further show that alignment and attraction, the two major traits forming the sociability personality axis in this species, showed heritability estimates at the upper end of the range previously described for social behaviours, with important variation across sexes. The results from both Pool-seq and RNA-seq data indicated that genes involved in neuron migration and synaptic function were instrumental in the evolution of sociability, highlighting a crucial role of glutamatergic synaptic function and calcium-dependent signalling processes in the evolution of schooling.