A controller for AC rotary machine configured to control an AC rotary machine which is provided with n-phase windings, wherein n is a natural number of greater than or equal to three, the controller for AC rotary machine comprising: an inverter that is provided with n sets of series circuits in each of which a positive electrode side switching device connected to a positive electrode side of a DC power source and a negative electrode side switching device connected to a negative electrode side of the DC power source are connected in series and a connection node of series connection is connected to the winding of the corresponding phase, corresponding to each phase of n-phase; n-phase current sensors each of which is connected in series to a detection object device which is the positive electrode side switching device or the negative electrode side switching device of each phase of n-phase, and configured to detect current; a current detection unit configured to detect current of each phase, based on an output signal of the current sensor of each phase, at a timing when the detection object device of each phase is turned on; a voltage command value calculation unit configured to calculate a voltage command value of each phase applied to the winding of each phase based on a current detection value of each phase; a PWM control unit configured to control on/off the switching devices of each phase by PWM control, based on the voltage command value of each phase; and a failure determination unit configured to determine a positive electrode side short circuit failure which is a short circuit failure of a part of the positive electrode side switching device, and a negative electrode side short circuit failure which is a short circuit failure of a part of the negative electrode side switching device, in the series circuit of each phase of the inverter, based on an on-off pattern of the positive electrode side switching device and the negative electrode side switching device each phase, and the current detection value of each phase, wherein, when it is determined that the positive electrode side short circuit failure or the negative electrode side short circuit failure of the series circuit of any one phase occurred, the voltage command value calculation unit is configured to calculate the voltage command values of normal n-1 phases that the short circuit failure does not occur; and to change the voltage command values of the normal n-1 phases so that on period of the detection object device of each phase of the normal n-1 phases become longer than or equal to a length necessary for current detection at least at a current detection timing, wherein, when it is determined that the short circuit failure occurred, the PWM control unit is configured to lengthen the control period (Tc) of the PWM control more than when it is not determined that the short circuit failure occurred. an inverter that is provided with n sets of series circuits in each of which a positive electrode side switching device connected to a positive electrode side of a DC power source and a negative electrode side switching device connected to a negative electrode side of the DC power source are connected in series and a connection node of series connection is connected to the winding of the corresponding phase, corresponding to each phase of n-phase; n-phase current sensors each of which is connected in series to a detection object device which is the positive electrode side switching device or the negative electrode side switching device of each phase of n-phase, and configured to detect current; a current detection unit configured to detect current of each phase, based on an output signal of the current sensor of each phase, at a timing when the detection object device of each phase is turned on; a voltage command value calculation unit configured to calculate a voltage command value of each phase applied to the winding of each phase based on a current detection value of each phase; a PWM control unit configured to control on/off the switching devices of each phase by PWM control, based on the voltage command value of each phase; and a failure determination unit configured to determine a positive electrode side short circuit failure which is a short circuit failure of a part of the positive electrode side switching device, and a negative electrode side short circuit failure which is a short circuit failure of a part of the negative electrode side switching device, in the series circuit of each phase of the inverter, based on an on-off pattern of the positive electrode side switching device and the negative electrode side switching device each phase, and the current detection value of each phase, wherein, when it is determined that the positive electrode side short circuit failure or the negative electrode side short circuit failure of the series circuit of any one phase occurred, the voltage command value calculation unit is configured to calculate the voltage command values of normal n-1 phases that the short circuit failure does not occur; and to change the voltage command values of the normal n-1 phases so that on period of the detection object device of each phase of the normal n-1 phases become longer than or equal to a length necessary for current detection at least at a current detection timing, wherein, when it is determined that the short circuit failure occurred, the PWM control unit is configured to lengthen the control period (Tc) of the PWM control more than when it is not determined that the short circuit failure occurred.