Experiments in the past suggest that hole traps at GaN/SiO2 interfaces are reduced with heavily Mg-doped GaN epitaxial layers, but its physical origin is unclear. In this study, we use first-principles calculations to investigate interactions between substitutional Mg atoms at Ga sites (MgGa) and O vacancies (VO) in the nanometer-scale Ga-oxide (GaOx) interfacial layers, which are inevitably formed at GaN/SiO2 interfaces. We clarify the physical reason why Mg passivates hole traps. Our calculations show that MgGa and VO become stable by forming 2MgGa–VO complex in GaOx. In addition, while VO form deep hole traps in the bandgap of GaN, Mg attachment to VO makes the hole-trap level shift upward substantially and thus 2MgGa–VO induces no hole traps. These results indicate that hole traps originated from VO are passivated by the formation of a complex of MgGa atoms and VO.