Discerning the relationship between sociality and longevity would permit a deeper understanding of how animal life history evolved. Here, we perform a phylogenetic comparative analysis of ~1000 mammalian species on three states of social organization (solitary, pair-living, and group-living) and longevity. We show that group-living species generally live longer than solitary species, and that the transition rate from a short-lived state to a long-lived state is higher in group-living than non-group-living species, altogether supporting the correlated evolution of social organization and longevity. The comparative brain transcriptomes of 94 mammalian species identify 31 genes, hormones and immunity-related pathways broadly involved in the association between social organization and longevity. Further selection features reveal twenty overlapping pathways under selection for both social organization and longevity. These results underscore a molecular basis for the influence of the social organization on longevity.