The outer atmosphere of the Sun is a magnetically-dominated environment. The magnetic field determines the transport, storage and dissipation of energy, in fairly steady ways (coronal heating, solar wind acceleration) but also in abrupt and impulsive events called solar flares. Solar flares represent the rapid conversion of energy in the magnetically stressed corona into plasma heating and the KE of accelerated particles and mass motions. Flares are now observed in exquisite detail with imaging and spectroscopy across the electromagnetic spectrum, allowing increasingly meaningful comparisons with detailed theory. In this talk I will give a general overview of recent flare observations and the framework in which they are interpreted, before focusing on one aspect of flare physics, namely the need to rapidly transport energy through the corona and accelerate particles. I will also place our knowledge of solar flares and their effect on Earth in the context of what we are learning about stellar flares and their possible impact on their planetary systems.