The invention proposes a power grid simulator having accurate harmonic voltage and virtual impedance control. The power grid simulator comprises a reactor, a rectification unit, a main inversion unit and an auxiliary inversion unit, wherein the rectification unit comprises a three-phase PWM rectifier and a PWM rectification controller, the main inversion unit comprises a main inverter and a main inversion controller, the auxiliary inversion unit comprises an auxiliary inverter and an auxiliary inversion controller, an input end of the three-phase PWM rectifier is accessed to a power grid through the reactor, an output end of the three-phase PWM rectifier is connected with the main inverter and the auxiliary inverter respectively, and an output end of the auxiliary inverter is connected with an output end of the main inverter. Compared with the prior art, the power grid simulator having accurate harmonic voltage and virtual impedance control, provided by the invention, has the advantages that a standard power grid output voltage, a power grid voltage fault working condition and a power grid harmonic component can be simulated, the power grid impedance change can also be simulated, and the demand of distributed power generation test research can be met very well.