Lotto Belisol's Greipel matched the three stages won by rival Sagan of Liquigas-Cannondale with a spirited finish on the Mediterranean coast on Bastille Day.
Team Sky's Edvald Boasson Hagen took third place in the sprint after being led out by team-mate Bradley Wiggins, who retained his yellow jersey after the 217km stage from Saint-Paul-Trois-Chateaux.
Greipel had his work cut out to return to the main pack after a steep Cat.3 climb 25km from the finish blew the race apart – and did for the chances of key sprinters Mark Cavendish (Team Sky) and Matt Goss (Orica-GreenEdge).
But the 29-year-old from Rostock was nursed back to the front of the race where a slick five-man Lotto Belisol train formed in pursuit of Kazakhstan’s Alexander Vinokourov (Astana) and Swiss Michael Albasini (GreenEdge) who had countered inside the final 16km.
The duo were swept up with 3km remaining before Wiggins led Boasson Hagen around the final downhill bend ahead of the closing straight.
Greipel powered past the Norwegian national champion and held off a late surge by Slovakian youngster Sagan to take his third win of the race and become the first German rider to record a hat-trick of wins in one Tour since Erik Zabel in 2001.
“The last 25km were really hard and I was second last in my group over the last climb so I had to fight to get back on,” said Greipel.
“I chose the wheel of Edvald – a really strong guy – and I knew I could win. I knew I had Sagan in my wheel – and he’s a really fast guy – but I think we deserve the win because we worked for it. I’m really happy with my team - it was awesome teamwork,” Greipel added.
Fitting for a French national holiday, five out of eight riders in the main break of the stage were Frenchmen riding for French teams as the host nation sought their fourth win of the race on Bastille Day.
Samuel Dumoulin (Cofidis), Matthieu Ladagnous (FDJ-BigMat), Jimmy Engoulvent (Saur-Sojasun), Maxime Bouet (Ag2r-La Mondiale) and Jerome Pineau (Omega Pharma-Quick Step) were joined by Spaniard Pablo Urtasun (Euskaltel), Dutchman Roy Curvers (Argos Shimano) and Denmark’s Michael Morkov (Saxo Bank-Tinkoff) in a break which built up a maximum lead of 12:20 over a largely flat parcours in sunny southern France.
The Orica-GreenEdge team of Goss had combined well on the front of the peloton to reduce the deficit to just over two minutes with 65km remaining when Morkov decided to go on an ambitious solo drive to the finish.
Looking for a win to honour his late father who passed away five years to the day, Morkov increased his lead to three and a half minutes over the peloton but was caught on the steep 10 per cent slope of the Mont Saint-Clair 23km from the finish. The Dane was poignantly awarded with the most aggressive rider award later.
Belgian Jurgen van den Broeck led a group of race favourite including Wiggins, Cadel Evans (BMC) and Vincenzo Nibali (Liquigas) over the summit of the punchy climb. A leading group of around 60 riders formed on the fast descent – and despite the blistering pace being set by Lotto Belisol on the approach to Cap d’Agde, Vinokourov managed to open up a small gap.
The Astana veteran was joined by Albasini and the pair combined for 10km but never held more than a slender 15-second gap on the streamlined peloton.
After a foiled break by Spaniard Luis Leon Sanchez (Rabobank), Wiggins tried his best to set up team-mate Boasson Hagen for the win.
“It was a nice gesture and probably a little thank-you for all the hard work Edvald has done for him in the mountains,” said Team Sky manager David Brailsford after the stage.
But Greipel proved the strongest of the remaining sprinters, holding off the challenge by 22-year-old Sagan, who had been carried along by the Lotto train for much of the final kilometres.
The German won by half a bike length, with Boasson Hagen firmly in third. Frenchman Sebastian Hinault (Ag2r-La Mondiale) took fourth place with South African Daryl Impey (GreenEdge) fifth.
There was no change at the top of the GC, with Wiggins maintaining a 2:05 gap over his team-mate Chris Froome, with Nibali 2:23 down in third and Evans 3:19 down in fourth.
The race returns to the hills on Sunday with the 191km stage 14 from Limoux to Foix, which includes two Cat.1 climbs in the final third of the race before a flat finish in the Pyrenean foothills.