We present three-dimensional force-free electrodynamics simulations of magnetar magnetospheres that demonstrate the instability of certain degenerate, high energy equilibrium solutions of the Grad-Shafranov equation. This result indicates the existence of an unstable branch of twisted magnetospheric solutions and allows to formulate an instability criterion. The rearrangement of magnetic field lines as a consequence of this instability triggers the dissipation of up to 30% of the magnetospheric energy on a thin layer above the magnetar surface. During this process, we predict an increase of the mechanical stresses onto the stellar crust, which can potentially result in a global mechanical failure of a significant fraction of it. We find that the estimated energy release and the emission properties are compatible with the observed giant flare events. The newly identified instability is a candidate for recurrent energy dissipation, which could explain part of the phenomenology observed in magnetars.