Solar flares are highly energetic events in the Sun’s corona that affect Earth’s space weather. The mechanism that drives the onset of solar flares is unknown, hampering efforts to forecast them, which mostly rely on empirical methods. We present the -scheme, a physics-based model to predict large solar flares through a critical condition of magnetohydrodynamic instability, triggered by magnetic reconnection. Analysis of the largest (X-class) flares from 2008 to 2019 (during solar cycle 24) shows that the -scheme predicts most imminent large solar flares, with a small number of exceptions for confined flares. We conclude that magnetic twist flux density, close to a magnetic polarity inversion line on the solar surface, determines when and where solar flares may occur and how large they can be.