An engine controller configured to control an engine , the engine including cylinders each provided with an intake valve and an exhaust valve , and a valve stopping mechanism capable of stopping an operation for opening and closing the intake valve and the exhaust valve of each of the cylinders , the engine controller comprising: a cylinder deactivation control unit configured to execute cylinder deactivation in at least one of the cylinders ; and a valve stopping control unit configured to execute, during the execution of the cylinder deactivation, a valve stopping control to control the valve stopping mechanism for stopping the operation for opening and closing the intake valve and the exhaust valve of a deactivated cylinder subject to the cylinder deactivation, wherein the valve stopping control unit is configured to stop the operation for opening and closing the exhaust valve of the deactivated cylinder from a first combustion cycle after starting the cylinder deactivation and stop the operation for opening and closing the intake valve of the deactivated cylinder from a second combustion cycle after starting the cylinder deactivation, such that cylinder deactivation is performed with intake air enclosed in the deactivated cylinder, when performing the valve stopping control in a case in which the cylinder deactivation control unit executes the cylinder deactivation with the deactivated cylinder fixed; and wherein the valve stopping control unit is configured to stop the operation for opening and closing both the intake valve and the exhaust valve of the deactivated cylinder from the first combustion cycle after starting the cylinder deactivation, such that cylinder deactivation is performed with the inside of the deactivated cylinder scavenged in the exhaust stroke immediately before starting the cylinder deactivation, when performing the valve stopping control in a case in which the cylinder deactivation control unit executes the cylinder deactivation without fixing the deactivated cylinder. a cylinder deactivation control unit configured to execute cylinder deactivation in at least one of the cylinders ; and a valve stopping control unit configured to execute, during the execution of the cylinder deactivation, a valve stopping control to control the valve stopping mechanism for stopping the operation for opening and closing the intake valve and the exhaust valve of a deactivated cylinder subject to the cylinder deactivation, wherein the valve stopping control unit is configured to stop the operation for opening and closing the exhaust valve of the deactivated cylinder from a first combustion cycle after starting the cylinder deactivation and stop the operation for opening and closing the intake valve of the deactivated cylinder from a second combustion cycle after starting the cylinder deactivation, such that cylinder deactivation is performed with intake air enclosed in the deactivated cylinder, when performing the valve stopping control in a case in which the cylinder deactivation control unit executes the cylinder deactivation with the deactivated cylinder fixed; and wherein the valve stopping control unit is configured to stop the operation for opening and closing both the intake valve and the exhaust valve of the deactivated cylinder from the first combustion cycle after starting the cylinder deactivation, such that cylinder deactivation is performed with the inside of the deactivated cylinder scavenged in the exhaust stroke immediately before starting the cylinder deactivation, when performing the valve stopping control in a case in which the cylinder deactivation control unit executes the cylinder deactivation without fixing the deactivated cylinder. <EOS>