The hour-long, gradual phase of solar flares is well observed across the electromagnetic spectrum, demonstrating many multiphase aspects, where cold condensations form within the heated post-flare system, but a complete 3D model is lacking. Using a state-of-the-art 3D magnetohydrodynamic simulation, we identify the key role played by the Lorentz force through the entire flare lifespan, and show that slow variations in the post-flare magnetic field achieve the bulk of the energy release. Synthetic images in multiple passbands closely match flare observations, and we quantify the role of conductive, radiative, and Lorentz force work contributions from flare onset to decay. This highlights how the non-force-free nature of the magnetic topology is crucial to trigger Rayleigh–Taylor dynamics, observed as waving coronal rays in extreme ultraviolet observations. Our C-class solar flare reproduces multiphase aspects such as post-flare coronal rain. In agreement with observations, we find strands of cooler plasma forming spontaneously by catastrophic cooling, leading to cool plasma draining down the post-flare loops. As there is force balance between magnetic pressure and tension and the plasma pressure in gradual-phase flare loops, this has potential for coronal seismology to decipher the magnetic field strength variation from observations.