Magnetically driven eruptions on the Sun, from stellar-scale coronal mass ejections1to small-scale coronal X-ray and extreme-ultraviolet jets2,3,4, have frequently been observed to involve the ejection of the highly stressed magnetic flux of a filament5,6,7,8,9. Theoretically, these two phenomena have been thought to arise through very different mechanisms: coronal mass ejections from an ideal (non-dissipative) process, whereby the energy release does not require a change in the magnetic topology, as in the kink or torus instability10,11; and coronal jets from a resistive process2,12involving magnetic reconnection. However, it was recently concluded from new observations that all coronal jets are driven by filament ejection, just like large mass ejections13. This suggests that the two phenomena have physically identical origin and hence that a single mechanism may be responsible, that is, either mass ejections arise from reconnection, or jets arise from an ideal instability. Here we report simulations of a coronal jet driven by filament ejection, whereby a region of highly sheared magnetic field near the solar surface becomes unstable and erupts. The results show that magnetic reconnection causes the energy release via ‘magnetic breakout’—a positive-feedback mechanism between filament ejection and reconnection. We conclude that if coronal mass ejections and jets are indeed of physically identical origin (although on different spatial scales) then magnetic reconnection (rather than an ideal process) must also underlie mass ejections, and that magnetic breakout is a universal model for solar eruptions.