Daryl Impey (Mitchelton-Scott) led out the bunch sprint in the final metres with teammate Matteo Trentin on the right, but the stage winner moved to the left and surged clear from the rest.
Wout van Aert (Jumbo-Visma) managed to claim second position, with Trentin taking third on the fifth stage.
“You just have to be patient and the victory will come. I have to say thanks to all my teammates, they did a very great job. Finally a Tour de France victory came for us, it’s very nice,” said Sagan.
He added that they controlled the race all day, on the flat part until the finish.
“I did my best and it came. If I don’t win, then everybody will ask me what is missing. You can see, nothing is missing. It’s just everybody needs good luck and a good day for a win.”
Earlier, three-time Tour de France stage winner Rui Costa attacked off the front of the bunch with 7.5km to the finish, but the former world champion was reigned back in with 2.5km to go.
The main break of the day comprised Mads Würtz Schmidt (Katusha-Alpecin), Tim Wellens (Lotto Soudal), Toms Skujins (Trek-Segafredo) and Simon Clarke (EF Education First), who had a maximum gap of 2:18.
After Schmidt was unable to hold the pace of the trio, Skujins attacked with 37km to go and had the remaining duo chasing.
He led the race for 15km until he made contact with the reduced bunch.
Julian Alaphilippe (Deceuninck-QuickStep) managed to keep the yellow jersey.