A GaN-based metal–semiconductor–metal varactor with a two-dimensional electron gas (2DEG) layer is proposed and fabricated. The capacitance variation of this fabricated varactor biased at different external voltages is studied and measured, and the frequency-dependent capacitance and resistance of the varactor are simulated by a corresponding empirical formula. A high-frequency protective filter is further constructed and placed under a large pulsed-current injection in a malicious electromagnetic interference immunity test. The results show that the proposed GaN-based module can reduce the large pulsed current to an acceptably small level. Thus, the GaN-based 2DEG varactor is an attractive candidate for applications designed to protect the upcoming 5G high-frequency system from risks such as electrostatic discharge, lightning, and electromagnetic pulses.