The sprinter came off the wheels of the Katusha train leading for Alexander Kristoff and held off André Greipel (Lotto-Soudal) and Peter Sagan (Tinkoff-Saxo). The stage win is his 26th in the race, and his first since stage 13 of the 2013 Tour.
"I just wanted to wait today, not hit out early today," Cavendish said. "You can see when I wait, I've got the speed."
Cavendish dedicated today's win to Tony Martin, who broke his collarbone and abandoned in the leader's yellow jersey yesterday.
"I almost didn't get it — I waited a bit too long," Cavendish added.
"André Greipel could have closed me out, but he let me have a clear sprint. That shows what a gentlemen he is."
Cavendish had 13 wins this year ahead of the Tour, but none in the top tier of WorldTour events. Last year's Tour de France ended with a crash on day one, which has meant a long wait to stand on the podium of the world's biggest race.
"I'm really happy after two years to win again," he said.
"The lads could've given up on me. They won two stages with Martin and [Zdenek] Stybar, and kept the patience in me after I messed up the sprint."
Martin won with a late attack on the cobbled fourth stage to Cambrai and took the yellow jersey. He lost it yesterday in a crash in the final kilometre, but team-mate Zdenek Stybar rode free for Etixx's second stage win.
The win comes at the right time for Cavendish, who is negotiating a new contract. It is unsure if he will stay with the Belgian team or switch for the 2016 season.
Thank you for reading 5 articles this month* Join now for unlimited access
Enjoy your first month for just £1 / $1 / €1
*Read 5 free articles per month without a subscription
Join now for unlimited access
Try first month for just £1 / $1 / €1