We investigate the incidence of early warfare among foragers and farmers in prehistory. Our focus is specifically on conflict over land. Food is produced using inputs of labor and land, and the probability of victory in a conflict depends on relative group sizes. The group sizes are determined by individual migration and Malthusian population dynamics. Both factors result in larger populations at better sites, which deters attack. There are two necessary conditions for warfare: high enough individual mobility costs and large enough shocks to the relative productivities of the sites. Together, these conditions are sufficient. In particular, technological or environmental shocks that alter the productivities of sites can trigger warfare, but only if individual agents do not change sites in response. These results are consistent with evidence from archaeology and anthropology.