We provide a quantitative test of the hypothesis that sex role specialization may account for sex differences in lifespan in baboons if such specialization causes the dependency of fitness upon longevity, and consequently the optimal resolution to an energetic trade-off between somatic maintenance and other physiological functions, to differ between males and females. We present a model in which females provide all offspring care and males compete for access to reproductive females and in which the partitioning of available energy between the competing fitness-enhancing functions of growth, maintenance, and reproduction is modeled as a dynamic behavioral game, with the optimal decision for each individual depending upon his/her state and the behavior of other members of the population. Our model replicates the sexual dimorphism in body size and sex differences in longevity and reproductive scheduling seen in natural populations of baboons. We show that this outcome is generally robust to perturbations in model parameters, an important finding given that the same behavior is seen across multiple populations and species in the wild. This supports the idea that sex differences in longevity result from differences in the value of somatic maintenance relative to other fitness-enhancing functions in keeping with the disposable soma theory.