A controller for rotary electric machine configured to control a rotary electric machine which is provided with a stator having plural-phase windings and a rotor having a magnet via an electric power converter, the controller for rotary electric machine comprising: a current detection unit configured to detect currents which flows into the plural-phase windings; a current coordinate conversion unit configured to convert current detection values into a current detection value of d-axis (Ids) and a current detection value of q-axis (Iqs) on a dq-axis rotating coordinate system consisting of a d-axis defined in a direction of a magnetic pole position of the rotor and a q-axis defined in a direction advanced to the d-axis by 90 degrees in an electrical angle, based on a rotational angle (θ) of the rotor; a current command value calculation unit configured to calculate a current command value of d-axis (Ido) and a current command value of q-axis (Iqo); a voltage command value calculation unit configured to change a voltage command value of d-axis (Vdo) and a voltage command value of q-axis (Vqo) so that the current detection value of d-axis (Ids) approaches the current command value of d-axis (Ido), and the current detection value of q-axis (Iqs) approaches the current command value of q-axis (Iqo); and to convert the voltage command value of d-axis (Vdo) and the voltage command value of q-axis (Vqo) into voltage command values of plural-phase, based on the rotational angle (θ); and a switching control unit configured to turn on and off a plurality of switching devices provided in the electric power converter, based on the voltage command values of plural-phase, characterised in that in a case where the current command value of q-axis (Iqo) is a positive value, the current command value calculation unit is configured to change the current command value of d-axis (Ido), based on a deviation (ΔIq_erroff) between an offset q-axis current command value (Iqoffo) obtained by subtracting a q-axis offset value (ΔIqoff) which is a positive value, from the current command value of q-axis (Iqo), and the current detection value of q-axis (Iqs). a current detection unit configured to detect currents which flows into the plural-phase windings; a current coordinate conversion unit configured to convert current detection values into a current detection value of d-axis (Ids) and a current detection value of q-axis (Iqs) on a dq-axis rotating coordinate system consisting of a d-axis defined in a direction of a magnetic pole position of the rotor and a q-axis defined in a direction advanced to the d-axis by 90 degrees in an electrical angle, based on a rotational angle (θ) of the rotor; a current command value calculation unit configured to calculate a current command value of d-axis (Ido) and a current command value of q-axis (Iqo); a voltage command value calculation unit configured to change a voltage command value of d-axis (Vdo) and a voltage command value of q-axis (Vqo) so that the current detection value of d-axis (Ids) approaches the current command value of d-axis (Ido), and the current detection value of q-axis (Iqs) approaches the current command value of q-axis (Iqo); and to convert the voltage command value of d-axis (Vdo) and the voltage command value of q-axis (Vqo) into voltage command values of plural-phase, based on the rotational angle (θ); and a switching control unit configured to turn on and off a plurality of switching devices provided in the electric power converter, based on the voltage command values of plural-phase, characterised in that in a case where the current command value of q-axis (Iqo) is a positive value, the current command value calculation unit is configured to change the current command value of d-axis (Ido), based on a deviation (ΔIq_erroff) between an offset q-axis current command value (Iqoffo) obtained by subtracting a q-axis offset value (ΔIqoff) which is a positive value, from the current command value of q-axis (Iqo), and the current detection value of q-axis (Iqs).