P-stars are compact stars made of up and down quarks in beta-equilibrium with electrons in a chromomagnetic condensate. P-stars are able to account for compact stars like RXJ 1856.5-3754 and RXJ 0720.4-3125, stars with radius comparable with canonical neutron stars, as well as super massive compact objects like SgrA*. We discuss p-stars endowed with super strong dipolar magnetic field which, following consolidated tradition in literature, are referred to as magnetars. We show that soft gamma-ray repeaters and anomalous X-ray pulsars can be understood within our theory. We find a well defined criterion to distinguish rotation powered pulsars from magnetic powered pulsars. We show that glitches, that in our magnetars are triggered by magnetic dissipative effects in the inner core, explain both the quiescent emission and bursts in soft gamma-ray repeaters and anomalous X-ray pulsars. We are able to account for the braking glitch from SGR 1900+14 and the normal glitch from AXP 1E 2259+586 following a giant burst. We discuss and explain the observed anti correlation between hardness ratio and intensity. Within our magnetar theory we are able to account quantitatively for light curves for both gamma-ray repeaters and anomalous X-ray pulsars. In particular we explain the puzzling light curve after the June 18, 2002 giant burst from AXP 1E 2259+586, so that we feel this last event as the Rosetta Stone for our theory. Finally, in Appendix we discuss the origin of the soft emission not only for soft gamma-ray repeaters and anomalous X-ray pulsars, but also for isolated X-ray pulsars. We also offer an explanation for the puzzling spectral features in 1E 1207.4-5209.