Abstract The Be- and Mg-content-dependent phase transition of BexMgyZn1−x−yO alloy is investigated by theoretically calculations and experiments. For a given content of Be, the maximum content of Mg at which the wurtzite structure still remains in BexMgyZn1−x−yO alloy is intensively studied. We find that as the content of Be increases, the maximum content of Mg in wurtzite BexMgyZn1−x−yO alloy increases accordingly. Moreover, the Be- and Mg-content-dependent band gap of the alloy at each wurtzite–rocksalt transition point is evaluated, which is expressed as an empirical law. In addition, the mechanism underlying the tunable band gap of the alloy in wurtzite BexMgyZn1−x−yO alloy is revealed.