The magnetosphere is the lens through which solar space weather phenomena are focused and directed towards the Earth. In particular, the non-linear interaction of the solar wind with the Earth's magnetic field leads to the formation of highly inhomogenous electrical currents in the ionosphere which can ultimately result in damage to and problems with the operation of power distribution networks. Since electric power is the fundamental cornerstone of modern life, the interruption of power is the primary pathway by which space weather has impact on human activity and technology. Consequently, in the context of space weather, it is the ability to predict geomagnetic activity that is of key importance. This is usually stated in terms of geomagnetic storms, but we argue that in fact it is the substorm phenomenon which contains the crucial physics, and therefore prediction of substorm occurrence, severity and duration, either within the context of a longer-lasting geomagnetic storm, but potentially also as an isolated event, is of critical importance. Here we review the physics of the magnetosphere in the frame of space weather forecasting, focusing on recent results, current understanding, and an assessment of probable future developments.