A controller for AC rotary electric machine that controls an AC rotary electric machine which is provided with a stator where three-phase windings are wound and a rotor, via an inverter which is provided a plurality of switching devices, the controller for AC rotary electric machine comprising: a voltage command calculation unit that calculates voltage command values of three-phase (Vub, Vvb, Vwb) applied to the three-phase windings, or a command voltage vector (Vo) which expresses voltages applied to the three-phase windings in a two-axis fixed coordinate system correlated with the three-phase windings; a zero phase voltage value calculation unit that switches n pieces (n is a natural number greater than or equal to two) of zero phase candidate voltage values (Vzc) whose values are different with each other, in order, for every switching period (Tv), and calculates as a zero phase voltage value (Vz); a voltage command correction unit that corrects the voltage command values of three-phase (Vub, Vvb, Vwb) or the command voltage vector (Vo), based on the zero phase voltage value (Vz); and a PWM control unit that controls on/off of the plurality of switching devices, based on the voltage command values of three-phase after correction (Vuc, Vvc, Vwc) or the command voltage vector after correction by the voltage command correction unit; and the controller for AC rotary electric machine is characterized in that the PWM control unit is configured to define a deviation between the zero phase voltage value (Vz), and a time lag zero phase voltage value obtained by delaying the zero phase voltage value (Vz) by a j times value of the switching period (Tv) (j is a natural number greater than or equal to one), as a zero phase time lag deviation value (Vzdif), j is a natural number which minimizes a difference between a half period of a mechanical resonance period (Tm) of the AC rotary electric machine, and the j times value of switching period (Tv), and the n pieces of zero phase candidate voltage values (Vzc) are preliminarily set so that an effective value (Vzdif_rms) of the zero phase time lag deviation value (Vzdif) becomes small compared with an effective value (VzAC_rms) of an AC component of the zero phase voltage value (Vz). a voltage command calculation unit that calculates voltage command values of three-phase (Vub, Vvb, Vwb) applied to the three-phase windings, or a command voltage vector (Vo) which expresses voltages applied to the three-phase windings in a two-axis fixed coordinate system correlated with the three-phase windings; a zero phase voltage value calculation unit that switches n pieces (n is a natural number greater than or equal to two) of zero phase candidate voltage values (Vzc) whose values are different with each other, in order, for every switching period (Tv), and calculates as a zero phase voltage value (Vz); a voltage command correction unit that corrects the voltage command values of three-phase (Vub, Vvb, Vwb) or the command voltage vector (Vo), based on the zero phase voltage value (Vz); and a PWM control unit that controls on/off of the plurality of switching devices, based on the voltage command values of three-phase after correction (Vuc, Vvc, Vwc) or the command voltage vector after correction by the voltage command correction unit; and the controller for AC rotary electric machine is characterized in that the PWM control unit is configured to define a deviation between the zero phase voltage value (Vz), and a time lag zero phase voltage value obtained by delaying the zero phase voltage value (Vz) by a j times value of the switching period (Tv) (j is a natural number greater than or equal to one), as a zero phase time lag deviation value (Vzdif), j is a natural number which minimizes a difference between a half period of a mechanical resonance period (Tm) of the AC rotary electric machine, and the j times value of switching period (Tv), and the n pieces of zero phase candidate voltage values (Vzc) are preliminarily set so that an effective value (Vzdif_rms) of the zero phase time lag deviation value (Vzdif) becomes small compared with an effective value (VzAC_rms) of an AC component of the zero phase voltage value (Vz).