Method and system embody a valve timing strategy to control the autoignition timing of a four stroke internal combustion engine (10) operated in an HCCI mode at different engine operating conditions such as different engine speed and torque. A particular valve timing strategy varies lift timing of the intake valve (20) relative to the exhaust valve (28), or vice versa, and relative to top dead center in response to a change in engine torque, for example, to vary amount of trapped residual burned gas in the combustion chamber (12) flowing to an intake or exhaust port (16,18) and back to the combustion chamber during which the residual gas is cooled. Control of the flow of residual gas between the combustion chamber and intake or exhaust port and thus its temperature by the valve timing strategy, in turn, is used to control the temperature of the fresh air/residual gas/fuel mixture in the combustion chamber (12) and thus autoignition timing in response to a change in engine torque.