A variable valve mechanism of an internal combustion engine, comprising: a switch arm that is driven by a cam; a main arm that drives a valve of the internal combustion engine when swinging; a switch pin attached to the main arm so as to be displaceable; and a displacing device that displaces the switch pin to a disconnected position (C-) to switch the variable valve mechanism to a disconnected state where the switch arm makes a relative reciprocating displacement relative to the main arm in an idle swing direction and in a return direction opposite thereto according to rotation of the cam, and that displaces the switch pin to a connected position (C+) to switch the variable valve mechanism to a connected state where the switch arm and the main arm swing together, wherein during switching from the disconnected state to the connected state, if the switch pin is displaced to the connected position (C+) while the switch arm is displaced in the idle swing direction relative to the main arm and thus the switch arm comes to an idle swing direction side with respect to the switch pin, the switch arm being displaced in the return direction relative to the main arm comes in sliding contact with a pin end surface of the switch pin, and the switch arm presses the pin end surface toward the disconnected position (C-) during a period between a sliding contact start time and a sliding contact end time so as to push back the switch pin, characterized in that in the case where a pressed center (p) is defined as a center position of a pressing force received from the switch arm at a sliding contact portion of the pin end surface with the switch arm, and a pin end surface length (Le) is defined as a length along the pin end surface from an idle-swing-side edge, which is an edge of the pin end surface on the idle swing direction side, to a return-side edge, which is an edge of the pin end surface on a return direction side, at least during a period from a 10% position time at which a length from the pressed center (p) to the return-side edge along the pin end surface is 10% of the pin end surface length (Le) to the sliding contact end time, a position of the pressed center (p) relative to the pin end surface shifts toward the return direction side without stopping as the switch arm is displaced toward the return direction relative to the main arm, so that the sliding contact ends without stopping of the pressed center (p) at the return-side edge. a switch arm that is driven by a cam; a main arm that drives a valve of the internal combustion engine when swinging; a switch pin attached to the main arm so as to be displaceable; and a displacing device that displaces the switch pin to a disconnected position (C-) to switch the variable valve mechanism to a disconnected state where the switch arm makes a relative reciprocating displacement relative to the main arm in an idle swing direction and in a return direction opposite thereto according to rotation of the cam, and that displaces the switch pin to a connected position (C+) to switch the variable valve mechanism to a connected state where the switch arm and the main arm swing together, wherein during switching from the disconnected state to the connected state, if the switch pin is displaced to the connected position (C+) while the switch arm is displaced in the idle swing direction relative to the main arm and thus the switch arm comes to an idle swing direction side with respect to the switch pin, the switch arm being displaced in the return direction relative to the main arm comes in sliding contact with a pin end surface of the switch pin, and the switch arm presses the pin end surface toward the disconnected position (C-) during a period between a sliding contact start time and a sliding contact end time so as to push back the switch pin, characterized in that in the case where a pressed center (p) is defined as a center position of a pressing force received from the switch arm at a sliding contact portion of the pin end surface with the switch arm, and a pin end surface length (Le) is defined as a length along the pin end surface from an idle-swing-side edge, which is an edge of the pin end surface on the idle swing direction side, to a return-side edge, which is an edge of the pin end surface on a return direction side, at least during a period from a 10% position time at which a length from the pressed center (p) to the return-side edge along the pin end surface is 10% of the pin end surface length (Le) to the sliding contact end time, a position of the pressed center (p) relative to the pin end surface shifts toward the return direction side without stopping as the switch arm is displaced toward the return direction relative to the main arm, so that the sliding contact ends without stopping of the pressed center (p) at the return-side edge.