We discuss gauge mediated supersymmetry breaking models which explain the observed muon anomalous magnetic moment and the Higgs boson mass simultaneously. The successful explanation requires the messenger sector which violates the relation motivated by the grand unification theory (GUT). The naive violation of the GUT relation, however, ends up with the CP problem. We propose a model in which the phases of the gaugino masses are aligned despite the violation of the GUT relation. We also consider a model which generates the $mu$-term and the additional Higgs soft masses squared without causing CP violation. As a result, we find a successful model which explains the muon anomalous magnetic moment and the Higgs boson mass. The model is also free from the CP, flavor-changing neutral current and the lepton flavor violation problems caused by the subdominant gravity mediation effects.