The magnetars are believed to be highly magnetized neutron stars having surface magnetic field 1014 − 1015 G. It is believed that at the center, the magnetic field may be higher than that at the surface. We study the effect of the magnetic field on the neutron star matter. We model the nuclear matter with the relativistic mean field approach considering the possibility of appearance of hyperons at higher density. We find that the effect of magnetic field on the matter of neutron stars and hence on the mass-radius relation is important, when the central magnetic field is atleast of the order of 1017 G. Very importantly, the effect of strong magnetic field reveals anisotropy to the system. Moreover, if the central field approaches 1019 G, then the matter becomes unstable which limits the maximum magnetic field at the center of magnetars. © 2015, World Scientific. All rights reserved.