Cells that reside within a community can cooperate and also compete with each other for resources. It remains unclear how these opposing interactions are resolved at the population level. Here we investigate such an internal conflict within a microbial (Bacillus subtilis) biofilm community: cells in the biofilm periphery not only protect interior cells from external attack but also starve them through nutrient consumption. We discover that this conflict between protection and starvation is resolved through emergence of long-range metabolic co-dependence between peripheral and interior cells. As a result, biofilm growth halts periodically, increasing nutrient availability for the sheltered interior cells. We show that this collective oscillation in biofilm growth benefits the community in the event of a chemical attack. These findings indicate that oscillations support population-level conflict resolution by coordinating competing metabolic demands in space and time, suggesting new strategies to control biofilm growth.