Compact stars can have either hadronic matter or can have exotic states of matter like strange quark matter or color superconducting matter . Stars also can have a quark core surrounded by hadronic matter , known as hybrid stars ( HS ) . The HS is likely to have a mixed phase in between the hadron and quark phase . Observational results suggest huge surface magnetic field in certain neutron stars ( NS ) called magnetars . Here we study the effect of strong magnetic field on the respective EOS of matter under extreme conditions . We further study the hadron-quark phase transition in the interiors of NS giving rise to hybrid stars ( HS ) in presence of strong magnetic field . The hadronic matter EOS is described based on relativistic mean field theory and we include the effect of strong magnetic fields leading to Landau quantization of the charged particles . For the quark phase we use the simple MIT bag model . We assume density dependent bag pressure and magnetic field . The magnetic field strength increases going from the surface to the center of the star . We construct the intermediate mixed phase using Glendenning conjecture . The magnetic field softens the EOS of both the matter phases . The effect of magnetic field is insignificant unless the field strength is above 10 ^ { 14 } G. A varying magnetic field , with surface field strength of 10 ^ { 14 } G and the central field strength of the order of 10 ^ { 17 } G has significant effect on both the stiffness and the mixed phase regime of the EOS . We finally study the mass-radius relationship for such type of mixed HS , calculating their maximum mass , and compare them with the recent observation of pulsar PSR J1614-2230 , which is about 2 solar mass . The observations puts a severe constraint on the EOS of matter at extreme conditions . The maximum mass with our EOS can reach the limit set by the observation .