Birmingham-born Martin went with a kilometre to go on the final climb and held off the late challenge of Pierre Roger Latour by a second.
Martin came home second the last time a Tour stage ended in Mur de Bretagne three years ago and he admitted he had been obsessed about winning here this time on a punchy climb that suited his abilities.
While his team once again showed cracks when finishing 15th of 22 squads in the stage three team time trial in Cholet last Monday, Martin's victory yesterday sees him move into 21st place overall, a minute and 27 seconds behind current race leader Greg Van Avermaet of BMC.
AG2R's Romain Bardet cracked in the heat of the final ascent and lost 31secs, while fellow contender Tom Dumoulin (Sunweb), the 2017 Giro d'Italia champion, lost almost a minute after suffering a mechanical problem.
"My first thoughts are that I hope my wife hasn't gone into labour", smiled Martin as he caught his breath.
President Trump loses 300K followers in Twitter purge
The social-media company warned on Wednesday that its crackdown on fake accounts means users will have fewer followers. Some of the losers are among so-called influencers who are paid huge amounts of money to post content on their pages.
BMC rider Porte, Italian Vincenzo Nibali and Britain's Geraint Thomas all crossed the line three seconds off the pace after the 181-kilometre ride from Brest to Mur de Bretagne, with defending champion Chris Froome five seconds further back.
Dumoulin and his Sunweb team compounded the mechanical mishap by getting a 20-second penalty when Dumoulin stayed too close to the team vehicle while trying to catch the pack, thereby benefiting from its draft that pulled him along. "Unfortunately I couldn't get a podium there, as I'd have had enough seconds to get the jersey". I had really good legs and when I went my legs kept coming and coming, " Martin said.
Joining Porte in those time gains was Irish stage victor Daniel Martin (UAE), Spaniards Alejandro Valverde (Movistar) and Mikel Landa (Movistar), Briton Adam Yates (Mitchelton-Scott), Welshman Geraint Thomas (Sky), Colombian Nairo Quintana (Movistar), Italian Vincenzo Nibali (Bahrain-Merida), and Dane Jacob Fuglsang (Astana).
Dumoulin, the time trial world champion and 2017 Giro d'Italia victor, was slowed by a tire puncture at the foot of the final ascent and lost 53 seconds.
Thomas picked up two bonus seconds during the stage, and left Froome in his wake on the final climb as he rode away from the reigning champion with a group of the other favourites.