Greipel, who also won stages four and five, prevailed at the end of a tricky 217-km ride from St Paul Trois Chateaux, timing his effort to perfection and resisting green jersey holder Sagan's fightback on the line.
Norway's Edvald Boasson Hagen, who benefited from Sky team mate Bradley Wiggins's unexpected lead-out effort in the final kilometre, took third place.
“"It is sometimes best to get to the front and repay a friend of mine a little bit," said Wiggins, who retained the overall leader's yellow jersey.
The Briton and his Team Sky controlled proceedings during the tricky, windy stage, and a couple of attempts by defending champion Cadel Evans on Mont St Clair, 16 kms from the finish, were easily reined in.
Overall Wiggins still leads team mate Chris Froome by 2:05 and Italy's Vincenzo Nibali by 2:23 as the Tour heads into the last week and the Pyrenees.
Mont St Clair is a short climb but it proved too steep for some of the leading sprinters in the peloton, such as world champion Mark Cavendish and Australia's Matthew Goss, who finished more than eight minutes off the pace.
Cavendish earned the consolation of receiving an award at the finish as the Tour's best ever sprinter in a poll by sports weekly l'Equipe Magazine.
Greipel and Sagan, by contrast, reached the top close to the leading bunch and managed to return in the descent.
“"This win is a special one with Mont St Clair so close to the finish. I managed to hang on in this climb and then Lars Bak took me back in the bunch," said Greipel.
With three team mates in the leading group and with cross winds splitting the peloton in several little bunches, the German quashed the last breakaway attempt by Kazakh Alexandre Vinokourov and Swiss Michael Albasini in the last 15 kms.
"“It was once again great team work. We deserved this," said Greipel, who retained a slim lead over Sagan on the line.
The Slovak, who has also won three stages in this year's race, increased his lead in the points classification, leaving Greipel 64 points behind.
The last man left to set-up the German for the final sprint was Belgian climber Jurgen van den Broeck, who was not really familiar with such a role.
Sunday's 14th stage will be a 191-km mountainous ride from Limoux to Foix featuring the punishing ascent to the Mur de Peguere.