An efficient carrier compensation mechanism in semiconductor layers by Fermi-level engineering is demonstrated using the modulation-doping of a deep acceptor and a shallow donor. The punch-through of the depletion region across the whole stack of modulation-doped layers shifts the Fermi level closer toward the midgap position, resulting in the compensation of residual background free carriers. The method represents an alternative to achieve semi-insulating properties in semiconductor materials where a suitable deep acceptor or donor state at the midgap position is not available. We demonstrate the applicability of the concept with a commercially important GaN case study using carbon (deep acceptor) and Si (shallow donor) doping. A strong enhancement of breakdown field strength and reduced charge pileup effects are observed due to the efficient pinning of the Fermi level.