The origins of the various outbursts of hard X-rays from magnetars (highly magnetized neutron stars) are still unknown. We identify instabilities in relativistic magnetospheres that can explain a range of X-ray flare luminosities. Crustal surface motions can twist the magnetar magnetosphere by shifting the frozen-in footpoints of magnetic field lines in current-carrying flux bundles. Axisymmetric (2D) magnetospheres exhibit strong eruptive dynamics, i.e., catastrophic lateral instabilities triggered by a critical footpoint displacement of ψ
crit ≳ π. In contrast, our new three-dimensional (3D) twist models with finite surface extension capture important non-axisymmetric dynamics of twisted force-free flux bundles in dipolar magnetospheres. Besides the well-established global eruption resulting (as in 2D) from lateral instabilities, such 3D structures can develop helical, kink-like dynamics, and dissipate energy locally (confined eruptions). Up to 25% of the induced twist energy is dissipated and available to power X-ray flares in powerful global eruptions, with most of our models showing an energy release in the range of the most common X-ray outbursts, ≲1043 erg. Such events occur when significant energy builds up while deeply buried in the dipole magnetosphere. Less energetic outbursts likely precede powerful flares, due to intermittent instabilities and confined eruptions of a continuously twisting flux tube. Upon reaching a critical state, global eruptions produce the necessary Poynting-flux-dominated outflows required by models prescribing the fast radio burst production in the magnetar wind—for example, via relativistic magnetic reconnection or shocks.