Why do armies sometimes surrender to the enemy and sometimes fight to the bitter end? Existing research has highlighted the importance of battlefield resolve for the onset, conduct and outcome of war, but has left these life-and-death decisions mostly unexplained. We know little about why battle-level surrender occurs, and why it stops. In this paper, we argue that surrender emerges from a collective action problem: success in battle requires that soldiers choose to fight as a unit rather than flee, but individual decisions to fight depend on whether soldiers expect their comrades to do the same. As a result, surrender becomes contagious across battles, as soldiers take cues from what other soldiers had done when they were in a similar position. Where no recent precedent exists, mass surrender is unlikely. We find empirical support for this claim using a new dataset of conventional battles in all interstate wars from 1939 to 2011. These findings advance our understanding of battlefield resolve, with broader implications for the design of political-military institutions and decisions to initiate, continue, and terminate war.