Kin and multilevel selection theories predict that genetic structure is required for the evolution of cooperation. However, local competition among relatives can limit cooperative benefits, antagonizing the evolution of cooperation. We show that several ecological factors determine the extent to which kin competition constrains cooperative benefits. In addition, we argue that cooperative acts that expand local carrying capacity are less constrained by kin competition than other cooperative traits, and are therefore more likely to evolve. These arguments are particularly relevant to microbial cooperation, which often involves the production of public goods that promote population expansion. The challenge now is to understand how an organism’s ecology influences how much cooperative groups contribute to future generations and thereby the evolution of cooperation.