A control device for an engine provided with an engine body where a cylinder is formed, and an exhaust passage through which exhaust gas discharged from the engine body flows, the control device comprising: an ignition plug configured to ignite a mixture gas inside the cylinder; an injector configured to change an air-fuel ratio inside the cylinder; a NO x sensor disposed in the exhaust passage and configured to detect a concentration of NO x in the exhaust gas; and a controller configured to control the ignition plug and the injector, and perform: a first control in which the ignition plug is controlled so that ignition is performed at one of a preset basic ignition timing, and an ignition timing after the basic ignition timing is corrected based on a combustion state of the mixture gas inside the cylinder, and a second control in which a target air-fuel ratio is made high when the NO x concentration detected by the NO x sensor is higher than a given target value and the injector is controlled so that the NO x concentration detected by the NO x sensor approaches the given target value, the controller is configured to suspend, when the ignition timing is corrected by the first control to a retarding side of the basic ignition timing, a correction of the air-fuel ratio inside the cylinder to a richer side even if the NO x concentration detected by the NO x sensor is a concentration at which the correction of the air-fuel ratio to the richer side is to be performed by the second control, the controller is configured to maintain, when the controller suspends the correction of the air-fuel ratio inside the cylinder to the richer side, the air-fuel ratio at a most recent target air-fuel ratio, and the controller is configured to perform partial compression ignition combustion in which spark ignition combustion of a portion of the mixture gas inside the cylinder is carried out by spark ignition and compression ignition combustion of the remaining mixture gas inside the cylinder is then carried out by self-ignition, and perform the second control in at least a part of an operating range where the partial compression ignition combustion is performed. an ignition plug configured to ignite a mixture gas inside the cylinder; an injector configured to change an air-fuel ratio inside the cylinder; a NO x sensor disposed in the exhaust passage and configured to detect a concentration of NO x in the exhaust gas; and a controller configured to control the ignition plug and the injector, and perform: a first control in which the ignition plug is controlled so that ignition is performed at one of a preset basic ignition timing, and an ignition timing after the basic ignition timing is corrected based on a combustion state of the mixture gas inside the cylinder, and a second control in which a target air-fuel ratio is made high when the NO x concentration detected by the NO x sensor is higher than a given target value and the injector is controlled so that the NO x concentration detected by the NO x sensor approaches the given target value, a first control in which the ignition plug is controlled so that ignition is performed at one of a preset basic ignition timing, and an ignition timing after the basic ignition timing is corrected based on a combustion state of the mixture gas inside the cylinder, and a second control in which a target air-fuel ratio is made high when the NO x concentration detected by the NO x sensor is higher than a given target value and the injector is controlled so that the NO x concentration detected by the NO x sensor approaches the given target value, the controller is configured to suspend, when the ignition timing is corrected by the first control to a retarding side of the basic ignition timing, a correction of the air-fuel ratio inside the cylinder to a richer side even if the NO x concentration detected by the NO x sensor is a concentration at which the correction of the air-fuel ratio to the richer side is to be performed by the second control, the controller is configured to maintain, when the controller suspends the correction of the air-fuel ratio inside the cylinder to the richer side, the air-fuel ratio at a most recent target air-fuel ratio, and the controller is configured to perform partial compression ignition combustion in which spark ignition combustion of a portion of the mixture gas inside the cylinder is carried out by spark ignition and compression ignition combustion of the remaining mixture gas inside the cylinder is then carried out by self-ignition, and perform the second control in at least a part of an operating range where the partial compression ignition combustion is performed.