An excavator has a controller capable of setting target torque of a rotation motor in accordance with a speed deviation between target speed set in accordance with an operation amount of an operating lever and actual rotation speed and is provided with an inverter for detecting necessary torque for rotating an upper rotating body, the necessary torque being changed in accordance with a working state of the upper rotating body. The controller calculates a correction amount which is increased as increasing the torque and subtracts the correction amount from the target speed so as to set new target speed. A controller sets first target torque for driving the motor and second target torque for maintaining the upper rotating body on the spot on the basis of the actual speed, and operates the motor in accordance with the torque which has a larger absolute value in the same direction as the first target torque among both the torque.