Both sides ended the game with 10 men after Thomas Mangani aimed a punch at Achraf Hakimi, who retaliated.
Fabian Ruiz and Hakimi struck in the first half for PSG.
Kylian Mbappe scored twice at the start of the second half before Mohamed Youssouf’s own goal as Ajaccio were relegated.
Ajaccio’s best chance came in the 67th minute when Mickael Barreto’s right-footed shot from outside the box just sailed over the bar.
Messi played the full 90 minutes, returning to action for PSG for the first time since he was suspended by the club for two weeks after travelling to Saudi Arabia without their permission.
Christophe Galtier’s PSG are just four points away from a record 11th French title.
They are six points clear of second-placed Lens with three more fixtures remaining.