We present an analytical model of a magnetar as a high-density magnetized quark bag. The effect of strong magnetic fields (B > 5 × 10 16 G) in the equation of state is considered. An analytic expression for the mass-radius relationship is found from the energy variational principle in general relativity. Our results are compared with observational evidence of possible quark and/or hybrid stars.