A controller for an internal combustion engine that includes: a rotational phase difference changing mechanism (6, 106) that changes a rotational phase difference of a camshaft (4, 104) with respect to a crankshaft; a guide passage that is restricted from rotating relative to the camshaft (4, 104) and that is restricted from being displaced in the axial direction with respect to the camshaft; a guided member that is able to be engaged with or disengaged from the guide passage; an operating member that is displaced in an axial direction of the camshaft (4, 104) through a relative displacement, in the axial direction, of the guide passage and the guided member, the relative displacement being caused by the rotation of the camshaft (4, 104); a valve operating characteristic changing mechanism (8, 108) that changes operating characteristics of a valve (12, 112) with respect to the rotation of the camshaft (4, 104) through a displacement of the operating member; and an actuator (66, 166) that receives an input command signal to drive the guided member to thereby engage the guided member with the guide passage, the controller characterized by comprising: a crank position calculation unit that calculates a rotational position of the crankshaft; a rotational phase difference calculation unit that calculates a rotational phase difference of the camshaft (4, 104) with respect to the crankshaft, the rotational phase difference being changed by the rotational phase difference changing mechanism (6, 106); an instruction unit that outputs a command signal to the actuator (66, 166) when the operating characteristics of the valve (12, 112) are changed and that determines a timing, at which the command signal is output to the actuator (66, 166), on the basis of the rotational position of the crankshaft; and a timing correction unit that corrects the timing, at which the command signal is output by the instruction unit, on the basis of the rotational phase difference of the camshaft (4, 104) with respect to the crankshaft. a rotational phase difference changing mechanism (6, 106) that changes a rotational phase difference of a camshaft (4, 104) with respect to a crankshaft; a guide passage that is restricted from rotating relative to the camshaft (4, 104) and that is restricted from being displaced in the axial direction with respect to the camshaft; a guided member that is able to be engaged with or disengaged from the guide passage; an operating member that is displaced in an axial direction of the camshaft (4, 104) through a relative displacement, in the axial direction, of the guide passage and the guided member, the relative displacement being caused by the rotation of the camshaft (4, 104); a valve operating characteristic changing mechanism (8, 108) that changes operating characteristics of a valve (12, 112) with respect to the rotation of the camshaft (4, 104) through a displacement of the operating member; and an actuator (66, 166) that receives an input command signal to drive the guided member to thereby engage the guided member with the guide passage, the controller characterized by comprising: a crank position calculation unit that calculates a rotational position of the crankshaft; a rotational phase difference calculation unit that calculates a rotational phase difference of the camshaft (4, 104) with respect to the crankshaft, the rotational phase difference being changed by the rotational phase difference changing mechanism (6, 106); an instruction unit that outputs a command signal to the actuator (66, 166) when the operating characteristics of the valve (12, 112) are changed and that determines a timing, at which the command signal is output to the actuator (66, 166), on the basis of the rotational position of the crankshaft; and a timing correction unit that corrects the timing, at which the command signal is output by the instruction unit, on the basis of the rotational phase difference of the camshaft (4, 104) with respect to the crankshaft. a crank position calculation unit that calculates a rotational position of the crankshaft; a rotational phase difference calculation unit that calculates a rotational phase difference of the camshaft (4, 104) with respect to the crankshaft, the rotational phase difference being changed by the rotational phase difference changing mechanism (6, 106); an instruction unit that outputs a command signal to the actuator (66, 166) when the operating characteristics of the valve (12, 112) are changed and that determines a timing, at which the command signal is output to the actuator (66, 166), on the basis of the rotational position of the crankshaft; and a timing correction unit that corrects the timing, at which the command signal is output by the instruction unit, on the basis of the rotational phase difference of the camshaft (4, 104) with respect to the crankshaft.