Victories for Borna Coric and Marin Cilic over Jeremy Chardy and Jo-Wilfried Tsonga respectively gave Croatia a 2-0 lead on day one of the final.
French Open doubles champions Mahut and Hugues-Herbert had to win to keep the host in the final and they delivered at a raucous Stade Pierre Mauroy, winning 6-4 6-4 3-6 7-6 (7-3) to raise the roof.
Cilic will be a strong favourite to seal a second Davis Cup title when he faces Chardy in the fourth rubber, with Tsonga and Coric due to meet in what France will hope to be a decider.
A stunning Mahut return set up the only break of a tense opening set in game seven, marking the first time Croatia had dropped serve in the 2018 final.
Serve was king again in the second, but France crucially saw off break point in game eight before breaking in the next game and going on to see out the set.
It looked like the writing was on the wall when France broke in game one of the third set, but Dodig and Pavic rallied to win four straight games from 3-2 down to drag themselves back into the match.
The French duo saw three break points come and go in the first game of the fourth, but were on the brink of victory when a double fault from Pavic gifted them three match points.
Mahut called on a partisan crowd to be silent and the Croatians were unimpressed with being made to wait due to the noise levels, but Pavic dug deep with a defiant hold after ordered was restored.
The Croatian pair fell short in the tie-break, though, Mahut earning two more match points with a blistering serve and then showing lightning quick reactions at the net to get the job done, sparking exuberant celebrations.