Wild herbivore populations are declining in many African savannas, which is related to replacement by livestock (mainly cattle) and the loss of megaherbivores. Although some livestock management practices may be compatible with the conservation of native savanna biodiversity, the sustainability of these integrated wild herbivore/livestock management practices is unknown. For instance, how will these herbivore mixes influence key processes for the long-term functioning of savanna ecosystems, such as soil carbon, nitrogen and phosphorus pools and cycling? The Kenya Long-term Exclosure Experiment studies the ecosystem consequences of manipulating the presence and absence of wild herbivores and cattle at moderate densities in a ‘black cotton’ savanna. Here we show that after 20 years, cattle presence decreased total soil carbon and nitrogen pools, while the presence of megaherbivores (mainly elephants) increased these pools and even reversed the negative effects of cattle. Our results suggest that a mix of cattle at moderate densities and wild herbivores can be sustainable, provided that the assemblage of wild herbivores includes the largest species. Cattle are replacing wildlife in many African savannas. This field study finds that wild megaherbivores, such as elephants, increased soil carbon and nitrogen, and hence soil fertility, normally lost when only cattle are present.