World food demand is expected to more than double by 2050. Decisions about how to meet this challenge will have profound effects on wild species and habitats. We show that farming is already the greatest extinction threat to birds (the best known taxon), and its adverse impacts look set to increase, especially in developing countries. Two competing solutions have been proposed: wildlife-friendly farming (which boosts densities of wild populations on farmland but may decrease agricultural yields) and land sparing (which minimizes demand for farmland by increasing yield). We present a model that identifies how to resolve the trade-off between these approaches. This shows that the best type of farming for species persistence depends on the demand for agricultural products and on how the population densities of different species on farmland change with agricultural yield. Empirical data on such density-yield functions are sparse, but evidence from a range of taxa in developing countries suggests that high-yield farming may allow more species to persist.