Sexual selection theory predicts a trade-off between premating (ornaments and armaments) and postmating (testes and ejaculates) sexual traits, assuming that growing and maintaining these traits is costly and that total reproductive investments are limited. The number of males in competition, the reproductive gains from investing in premating sexual traits, and the level of sperm competition are all predicted to influence how males allocate their finite resources to these traits. Yet, empirical examination of these predictions is currently scarce. Here, we studied relative expenditure on pre- and postmating sexual traits among frog species varying in their population density, operational sex ratio, and the number of competing males for each clutch of eggs. We found that the intensifying struggle to monopolize fertilizations as more and more males clasp the same female to fertilize her eggs shifts male reproductive investment toward sperm production and away from male weaponry. This shift, which is mediated by population density and the associated level of male–male competition, likely also explains the trade-off between pre- and postmating sexual traits in our much broader sample of anuran species. Our results highlight the power of such a multilevel approach in resolving the evolution of traits and allocation trade-offs.