Identifying the genetic architecture underlying phenotypic variation in natural populations and assessing the consequences of polymorphisms for individual fitness are fundamental goals in evolutionary and molecular ecology. Consistent between-individual differences in behaviour have been documented for a variety of taxa. Dissecting the genetic basis of such behavioural differences is however a challenging endeavour. The molecular underpinnings of natural variation in aggression remain elusive. Here, we used comparative gene expression (transcriptome analysis and RT-PCR), genetic association analysis and pharmacological experiments to gain insight into the genetic basis of aggression in wild-caught jumping spiders (Portia labiata). We show that spider aggression is associated with a putative viral infection response gene, BTB/POZ domain-containing protein 17 (BTBDH), in addition to a putative serotonin receptor 1A (5-HT1A) gene. Spider aggression varies with virus loads, and BTBDH is upregulated in docile spiders and exhibits a genetic variant associated with aggression. We also identify a putative serotonin receptor 5-HT1A gene upregulated in docile P. labiata. Individuals that have been treated with serotonin become less aggressive, but individuals treated with a nonselective serotonin receptor antagonist (methiothepin) also reduce aggression. Further, we identify the genetic variants in the 5-HT1A gene that are associated with individual variation in aggression. We therefore conclude that co-evolution of the immune and nervous systems may have shaped the between-individual variation in aggression in natural populations of jumping spiders.