Bora-Hansgrohe’s Sagan won by a wheel length from Alexander Kristoff of UAE Team Emirates.
Both overhauled French hope Arnaud Demare of Groupama-FDJ in the final few metres of the 169.5km stage from Bourg d’Oisans.
It is a third victory of the Tour for Sagan, who extends his advantage in the points classification.
Quick-Step Floors’ Philippe Gilbert tried to take advantage of a slight drag up to the finish line and the decimation of the sprint field through abandonments in recent days as he attacked when they passed under the flamme rouge.
The Belgian was caught with 300m to go, leaving the fast men to fight it out.
Sagan won stages two and six of this Tour, and now has 11 Tour stage wins to his name.
Team Sky’s Thomas was looking forward to a quieter day after the drama of his back-to-back mountain stage wins in the Alps as the race rolled out of the hills and began the journey west towards the Pyrenees.
While there was no drama for Thomas in racing terms there was an incident inside the final 20kmwhen a spectator appeared to throw a lit flare into the peloton, close to head height for the passing Sky riders who were on that side of the road, though all of the riders passed safely.
Thomas crossed the line in 25th place on the day, with all the main contenders together to keep the same time gaps.
Thomas leads the race by one minute 39 seconds from team-mate Chris Froome, with Team Sunweb’s Tom Dumoulin a further 11 seconds back.
LottoNL-Jumbo’s Primoz Roglic is fourth, two minutes and 46 seconds down, after Bahrain-Merida’s Vincenzo Nibali was forced to withdraw having crashed on Thursday’s stage to Alpe d’Huez.
Thomas said he had not seen the flare.
“I didn’t actually notice it,” he said. “Sixteen kilometres to go did you say? I was fully in the zone then fighting for position. It was pretty stressful so I had no idea.”
However, the Welshman did, for a third straight day, hear boos as he collected his yellow jersey.
Asked why there was jeering, he said: “I think that’s a question for the people out there. I don’t know. We just train hard, work hard and come here to try to win the race. That’s a question for the people on the side of the road.”
Meanwhile, Tour de France director Christian Prudhomme has called for calm from fans after Froome was slapped and apparently spat at on the climb to Alpe d’Huez on Thursday.
Team Sky’s Froome was struck by at least one spectator a little under seven kilometres from the summit of the famous climb and seemed to be spat at shortly after, on his way to a fourth-placed finish as team-mate Thomas took victory.
There had been fears about security on the mountain – where large crowds are within touching distance of riders – with Froome still facing lingering ill-feeling among some cycling fans following the salbutamol case in which he was cleared of wrongdoing just days before the Tour began.
Speaking yesterday Prudhomme described the behaviour of some fans as “immoral” as he called for respect.
“We need to restore calm and respect all the riders,” he said. “It was a very annoying climb of the Alpe d’Huez. The riders on the Tour, and champions of the Tour, must obviously be respected as they are by the large majority of the public.
“By the roadside it was very calm for 10 days, with only a few anti-Froome or anti-Sky placards. But at a stroke it all went up again.
“I can only renew my appeals for calm, for common sense, with regards to the riders who make up the Tour de France.”
Froome said: “When you’ve got fans touching and interfering with the riders, who are doing everything to try and get up the climb, that’s not a situation anyone wants to see. That’s not acceptable.
“I was pushed a few times, but thankfully I stayed on my bike and didn’t get knocked off.”