Ludovic Blas pulled one back for the visitors and Ignatius Ganago equalised, but Mbappe set up Danilo Pereira to put PSG back in front on the hour mark and then claimed his record-breaking goal late on.
Mbappe reached the record in just 247 appearances since signing from Monaco aged 18 in 2017.
Uruguay star Cavani needed 298 games, and seven years, to establish the previous record in 2020.
The 24-year-old Mbappe was handed a trophy by the club after the game to mark his record in an on-field presentation.
“I play to make history and I have always said I wanted to make history in France, in the capital of my country, in my city, and I am doing that. It’s magnificent, but there is still a lot to be done,” Mbappe, who finished the game as captain, told broadcaster Canal Plus.
“For me, as a native Parisian, this is special. If someone had said to me I would score the goal to beat the record while wearing the captain’s armband, I would not have believed it.”
The result saw PSG open up a lead of 11 points at the top of Ligue 1 before nearest rivals Marseille play on Sunday, and before the Qatar-owned club go to Bayern for the second leg of their Champions League last-16 tie on Wednesday.
PSG trail 1-0 from the first leg against the Bavarians and failure to progress to the quarter-finals in Europe would put a major dampener on the end of their season.
Hakimi watches from stands
Injured Moroccan star Achraf Hakimi watched from the stands at the Parc des Princes a day after he was charged with rape following accusations made by a 24-year-old woman.
Neymar was also a spectator and will not be back for the match against Bayern, while centre-back Presnel Kimpembe is set to miss the remainder of the season with an achilles injury.
Coach Christophe Galtier lost two more defenders to injury in the second half against Nantes, with skipper Marquinhos and stand-in right-back Nordi Mukiele both having to come off.
Before the game there was a minute’s applause for Just Fontaine, the legendary former France striker who scored 13 goals at the 1958 World Cup and who passed away on Wednesday aged 89.
Fontaine also coached PSG, leading them to promotion to the top tier of French football in 1974.
The Parisians went ahead in the 12th minute, with Messi turning in a deflected low cross from Nuno Mendes to score his 13th Ligue 1 goal this season.
The unfortunate Hadjam’s own goal had PSG cruising, but a Blas shot that surprised Gianluigi Donnarumma just after the half-hour mark brought Nantes back into the game and Cameroonian forward Ganago’s header made it 2-2 before the break.
PSG had also blown a two-goal lead in their last home game against Lille a fortnight ago before recovering to win 4-3, and they repeated the feat here with Mbappe playing a starring role.
His assist was headed in by Danilo to make it 3-2 just before the hosts were awarded a penalty for a foul on Mukiele, only for a VAR check to rule that the contact had taken place outside the box.
It looked like Mbappe would be made to wait for his record before he struck right at the end with a finish on the turn.
Earlier Lens missed the chance to climb above Marseille into second place as they drew 1-1 at home to northern rivals Lille, for whom Canada star Jonathan David grabbed the equaliser.