The well-known Giudice-Masiero mechanism explains the presence of a μ term of the order of the gravitino mass, but does not explain why the holomorphic mass term is absent in the supzerpotential. We discuss anomaly-free discrete symmetries which are both compatible with SU(5) unification of matter and the Giudice-Masiero mechanism, i.e. forbid the μ term in the superpotential while allowing the necessary Kähler potential term. We find that these are ZMR symmetries with the following properties: (i) M is a multiple of four; (ii) the Higgs bilinear H uH d transforms trivially; (iii) the superspace coordinate θ has charge M/4 and, accordingly, the superpotential has charge M/2; (iv) dimension-five proton decay operators are automatically absent. All ZMR symmetries are anomaly-free due to a non-trivial transformation of a Green-Schwarz axion, and, as a consequence, a holomorphic μ term appears at the non-perturbative level. There is a unique symmetry that is consistent with the Weinberg operator while there is a class of ZMR symmetries which explain suppressed Dirac neutrino masses. © 2012 Elsevier B.V.