The 2002 French presidential election was a hard-fought contest, widely expected to be a rematch between incumbent Republican Jacques Chirac and Socialist Prime Minister Lionel Jospin. The widely-expected nature of the contest would ironically almost mean it never happened that way. The far-right candidate of the Front National (FN), Jean-Marie Le Pen, benefited from enormous vote splitting against Jospin from opponents to his left, including Ardlette Laguiller of Workers' Struggle, Jean-Pierre Chevènement of the Citizens' Movement, Noël Mamère of EELV (the French Greens) and Olivier Besancenot of the Revolutionary Communist League, who took almost 20,5% of the vote combined- more than Jospin's entire voteshare- and it was only by less than 0,2% that Jospin edged out Le Pen to face Chirac in the second round, with 16,6% for Jospin to 16,5% for Le Pen. Chirac took just over 20%.
This result served as a wake-up call to the left, which had been quite critical of Jospin's economic policies, and to Jospin himself. He shifted his campaign to the left economically, citing his government's reduction of social and economic inequality, calling for housing to be made a universal right and continuing policies like increasing welfare and progressive income tax programmes. Jospin also tried to deflect criticism of his government as soft on on law and order by reminding voters of Chirac's corruption allegations as mayor of Paris and his Presidential immunity if he won re-election, with one effective ad utilizing the phrase '
tire le tapis sous lui' ('pull out the rug from under him').
As the polls had predicted, the race was extremely close. In the end, Jospin beat Chirac on his second attempt, getting 51,7% of the vote to 48,3% for Chirac in what was the second-closest presidential election in history at the time. In the legislative elections held in June, the Gauche Plurielle ('Plural Left') coalition led by the Socialists was re-elected fairly comfortably, and ironically given its shockingly strong result in the first round of the presidential election, the FN lost a huge chunk of its May vote.
The 'Plural Left' would not have an easy second term, though, as infighting became prominent. The promised spending commitments Jospin made were ultimately substantially watered down and the claim of housing as a universal right was implemented in a way Jospin's left-wing critics described as little more than a platitude. Noël Mamère attracted the condemnation of Jospin for officiating a same-sex marriage ceremony in 2004, alienating socially liberal voters and driving the Greens out of the coalition. The same year's regional elections saw the left lose badly, and by 2007, when his term ended, Jospin was a pariah among the left, with the Republicans ripe to capitalize.
(Apologies for the lack of margin colours, I can't find the percentage margins for the departments for some reason, just raw vote totals.)