A controller that is configured to control a power conversion circuit that is configured to drive an alternating-current motor , the controller , comprising: a voltage command calculation unit that is configured to calculate a voltage command for operating the power conversion circuit on a basis of a current deviation corresponding to a difference between a current command and an actual current flowing through the alternating-current motor ; a control state judgement unit that is configured to output a judgement signal corresponding to a control state of the power conversion circuit on a basis of the current deviation; and a control gain change unit that is configured to change a control gain used for the voltage command calculation unit to calculate the voltage command on a basis of the judgement signal, wherein the control state judgement unit is configured to output a first judgement signal when the current deviation satisfies a predetermined range condition and is configured to output a second judgement signal when the current deviation does not satisfy the range condition, characterized in that the control gain change unit is configured to immediately change the control gain to a value corresponding to the second judgement signal when a judgement signal output from the control state judgement unit is switched from the first judgement signal to the second judgement signal, and is configured to change, with a predetermined delay time, the control gain to a value corresponding to the first judgement signal when a judgement signal output from the control state judgement unit is switched from the second judgement signal to the first judgement signal, wherein the control gain change unit has an integrator and is configured to realize the delay time by using the integrator, wherein the control gain change unit is configured to determine a value of the control gain on a basis of a value obtained by integrating, using the integrator , an absolute value of the current deviation. a voltage command calculation unit that is configured to calculate a voltage command for operating the power conversion circuit on a basis of a current deviation corresponding to a difference between a current command and an actual current flowing through the alternating-current motor ; a control state judgement unit that is configured to output a judgement signal corresponding to a control state of the power conversion circuit on a basis of the current deviation; and a control gain change unit that is configured to change a control gain used for the voltage command calculation unit to calculate the voltage command on a basis of the judgement signal, wherein the control state judgement unit is configured to output a first judgement signal when the current deviation satisfies a predetermined range condition and is configured to output a second judgement signal when the current deviation does not satisfy the range condition, characterized in that the control gain change unit is configured to immediately change the control gain to a value corresponding to the second judgement signal when a judgement signal output from the control state judgement unit is switched from the first judgement signal to the second judgement signal, and is configured to change, with a predetermined delay time, the control gain to a value corresponding to the first judgement signal when a judgement signal output from the control state judgement unit is switched from the second judgement signal to the first judgement signal, wherein the control gain change unit has an integrator and is configured to realize the delay time by using the integrator, wherein the control gain change unit is configured to determine a value of the control gain on a basis of a value obtained by integrating, using the integrator , an absolute value of the current deviation. <EOS>