Fiji had won all 17 of their previous matches in the Olympics and went ahead through Joseva Talacolo.
The home fans exploded when Rayan Rebbadj, who scored twice in the semi-final win over South Africa earlier, dived between the posts to level the scores at halftime.
Superstar scrumhalf Dupont then came off the bench to set up Aaron Grandidier Nkanang and then barrelled over himself to make it 21-7.
The 67,000 crowd could barely control themselves as France then controlled the ball in the final minutes and almost took the roof off when Dupont crashed over in the final play of the match.
Earlier, South Africa beat six-man Australia 26-19 with a last-play try by Shaun Williams to take the bronze medal.