The planetary perturbations on Mercury's orbit lead to long-period forced librations of Mercury's mantle. These librations have previously been studied for a planet with two layers: a mantle and a liquid core. Here, we calculate how the presence of a solid inner core in the liquid outer core influences the long-period forced librations. Mantle–inner core coupling affects the long-period libration dynamics mainly by changing the free libration: first, it lengthens the period of the free libration of the mantle, and second, it adds a second free libration, closely related to the free gravitational oscillation between the mantle and inner core. The two free librations have periods between 2.5 and 18y depending on the internal structure. We show that large amplitude long-period librations of a few tens of arcsec are generated when the period of a planetary forcing approaches one of the two free libration periods. These amplitudes are sufficiently large to be detectable by spacecraft measurements of the libration of Mercury. The amplitudes of the angular velocity of Mercury's mantle at planetary forcing periods are also amplified by the resonances, but remain much smaller than the current precision of Earth-based radar observations unless the period is very close to a free libration period. The inclusion of mantle–inner core coupling in the rotation model does not significantly improve the fit to the radar observations. This implies that it is not yet possible to determine the size of the inner core of Mercury on the basis of available observations of Mercury's rotation rate. Future observations of the long-period librations may be used to constrain the interior structure of Mercury, including the size of its inner core.