An apparatus for controlling a spark ignited internal combustion engine comprising a control unit including a memory having first and second tables containing the desired relationships between the engine condition and the spark timing for the engine operating on low and high octane fuels. The control unit calculates a value corresponding to a setting of the spark timing repetitively at uniform intervals from the first table in response to a first level of the control signal and from the second table in response to a second level of the control signal and advances the spark timing at a predetermined rate in the presence of the first level of the control signal and changes to the second level when the spark timing is advanced over a first reference value. The control unit retards the spark timing at a second predetermined rate in response to engine knock in the presence of the second level of the control signal and changes the control signal to the first level when the spark timing is retarded over a second reference value. The control unit stores a maximum advance value beta max to which the spark timing is advanced before the spark timing is advanced at the first predetermined rate during the successive advance control. The control unit clears the maximum advance value beta max to zero when the spark timing is advanced over the first reference value during the advance control.