Nature abounds with a rich variety of altruistic strategies, including public resource enhancement, resource provisioning, communal foraging, alarm calling, and nest defense. Yet, despite their vastly different ecological roles, current theory typically treats diverse altruistic traits as being favored under the same general conditions. Here, we introduce greater ecological realism into social evolution theory and find evidence of at least four distinct modes of altruism. Contrary to existing theory, we find that altruistic traits contributing to “resource-enhancement” (e.g., siderophore production, provisioning, agriculture) and “resource-efficiency” (e.g., pack hunting, communication) are most strongly favored when there is strong local competition. These resource-based modes of helping are “K-strategies” that increase a social group's growth yield, and should characterize species with scarce resources and/or high local crowding caused by low mortality, high fecundity, and/or mortality occurring late in the process of resource-acquisition. The opposite conditions, namely weak local competition (abundant resource, low crowding), favor survival (e.g., nest defense) and fecundity (e.g., nurse workers) altruism, which are “r-strategies” that increase a social group's growth rate. We find that survival altruism is uniquely favored by a novel evolutionary force that we call “sunk cost selection.” Sunk cost selection favors helping that prevents resources from being wasted on individuals destined to die before reproduction. Our results contribute to explaining the observed natural diversity of altruistic strategies, reveal the necessary connection between the evolution and the ecology of sociality, and correct the widespread but inaccurate view that local competition uniformly impedes the evolution of altruism.