rop yields in sub-Saharan Africa (SSA) are generally much lower than elsewhere. For instance, average maize yield in SSA is 1,446 kg ha −1 , whereas average global maize yield, excluding SSA, is 5,783 kg ha −1 (refs. 1,2 ), and increasing agricultural productivity in SSA could improve food security and rural welfare [3][4][5][6][7][8] . Increasing staple crop yield, the amount produced per unit cropland area, is also considered an important strategy to mitigate crop area expansion, and thus spare land for nature 9 . It is technically possible to strongly increase crop yields in many regions of SSA because there are large 'ecological yield gaps' , the differences between the actual crop yields and the crop yields that could be attained given available technology and the soil and weather conditions 3,4 . Reported national average ecological yield gaps for rainfed maize are as high as 4,800 kg ha −1 for Tanzania and Burkina Faso and over 9,000 kg ha −1 for Nigeria and Ethiopia 10 .To achieve such substantially higher crop yields, farmers would need to intensify their production systems in several ways. While there are different approaches to increase yields, in all cases farmers would need to use much more fertilizer than they currently do [11][12][13] , and it is not clear if and/or where this would be economically sensible from the farmers' perspectives. The profitability of fertilizer use depends on the effective local price of fertilizer and crop outputs, and on the local crop response to fertilizer. Reported maize responses to nitrogen fertilizer across SSA vary between 5 and 53 kg grain per kg N applied (refs. [14][15][16][17][18][19] ), and fertilizer use has been found to be profitable in some regions [20][21][22][23][24] , but not in others 25,26 , with considerable variation within countries. It is a challenge to generalize such reports because of the spatial variation in input and output prices, as well as in crop responses to fertilizer.To better understand opportunities for increasing staple food production in SSA through increased use of fertilizers, we evaluated location-specific ecological and economic conditions and how they affect crop responses to and economic returns on fertilizer investments. We compiled high-spatial-resolution data on soils, weather and local prices of fertilizer and maize grain. To predict crop response to fertilizer, we used an empirical machine-learning model derived from 12,081 observations from maize trials in 1,141 unique locations across SSA, and a mechanistic (rule-based) fertilizer response model called QUEFTS. Both models were used to predict maize yield in response to 539 different fertilizer applications combinations of nitrogen (0-200 kg ha −1 ), phosphorus and potassium (0-100 kg ha −1 ) for all 9 × 9 km spatial resolution grid cells of maize production in SSA.