Jumbo-Visma's Roglič romped it home by several lengths over fellow Slovenian Tadej Pogačar (UAE), with Guillaume Martin finishing third.
Martin came close to securing Cofidis' first victory at the Tour de France since 2008, attacking 500m from the line, but Roglič's patience paid off as he launched his own attack nearer the finish.
But Roglič's bonus seconds were all that separated him from his major rivals who finished together minus Emanuel Buchmann (BORA-hansgrohe) back in 17th and nine seconds behind.
It was the first real test for the Slovenian after crashing out of the Critérium du Dauphiné before the final stage. And he and his fellow bumblebees passed with flying colours, controlling the bunch on the final climb.
'It was quite a fast day, quite hard but the guys did again a really good job I was all the time in a good position and in the end I could do a nice sprint so very happy.
"Coming back what can I say. We see that I still am coming back now I can race. Every day I am feeling better.
"It's nice to ride a bike again."
Alaphilippe too finished with the major contenders and retains the yellow jersey. Asked if this bothered him, Roglic answered "it's the news that I have to accept. I don't really care. It's a nice day. We stay safe. At the end we win, even better. We have to continue like that."
Australia's Richie Porte finished in the same time and sits 16th on the general classification.
The 160km stage started with an attack from the flag drop as Nils Politt, Krists Neilands (Israel Start-Up Nation), Mathieu Burgaudeau (Total Direct Energie), Alexis Vuillermoz (AG2R-La Mondiale), Tiesj Benoot (Sunweb) and Quentin Pacher (B&B Hotels-Vital Concept) establishing their freedom by three and half minutes, 15kms later.
With the breakaway hoovering up all but the last of the intermediate sprint points after 50kms raced, Sam Bennett (Deceuninck-Quick-Step) fought hard for the scraps. Sagan appeared irritated with the result as the Irishman moved to 83 points, equalising the fight for the green jersey. But Mr Maillot Vert continues to hulk it up as he has an 11 minute advantage over Bennett in terms of the general classification.
On the ascent of the Col du Festre, Pacher pulled clear of the break 500m from the top to claim two KOM points where he was reabsorbed. Politt escaped on the descent but the break found him again with 70km to go with the advantage back to the bunch at just over three minutes. Pacher also took one point on the Côtes-de-Corps.
The leaders' advantage was kept in check by the peloton as many looked upon the final category 1 summit finish with glee.
At 26kms to go, Benoot was lucky to escape a crash on the descent, Neilands making the most of the disruption escaping alone up the road. The Latvian was reunited with the peloton 8kms from the finish as Jumbo-Visma took charge on the final climb.
The Tour de France continues with Stage 5 from Gap to Privas, with a slight uphill sprint to the line at the finish. The race action starts on the SBS ŠKODA Tour Tracker from 9.00pm AEST, with coverage beginning on SBS HD and SBS On Demand from 9.30pm.