The Slovak rode what was close to a perfect race, remaining completely anonymous for the entire race, and only putting himself in the wind for the final hundred metres as he edged past home favourite Alexander Kristoff (Norway).
None of the other road races at the World Championships had come down to bunch sprints, and the elite men's race looked like it could be heading in the same direction as Julian Alaphilippe (France) launched a powerful attack on the final climb, being joined by Gianni Moscon (Italy) and opening a decent lead with 10km remaining.
With four kilometres remaining Alaphilippe went solo, but was caught before the flamme rouge as the remaining sprinters got into position for the final kick.
Kristoff was the first to launch his sprint as the peloton came round the final corner with 300m remaining, and looked as if he could deliver a dream home victory for the Norwegian crowd.
However Sagan was primed to spoil the party, and as the line came closer, the two-time world champion edged alongside then passed Kristoff to win by half a wheel, in so doing becoming the first man to win three consecutive World Championships.
How it happened
The final event of a stellar World Championships in Bergen was the men's road race, which saw plenty of early attacks as Conor Dunne (Ireland) launched the first move of the 267.5km race.
Dunne was followed by team-mate Sean McKenna and Elchin Azadov (Azerbaijan). Those three riders were joined first by Eugert Zhupa (Albania) and Salaheddin Mraouni (Morocco), and then by Alex Vermeulen (USA), Andrey Amador (Costa Rica), Willem Jakobus Smit (South Africa), Matti Manninen (Finland), and Kim Magnusson (Sweden).
Those 10 riders quickly built a large lead as the peloton seemed more interested in enjoying the spectacular Norwegian scenery than doing any sort of chasing.
By the time the race entered the finishing circuit after 40km, the lead had grown to ten minutes as the big teams, especially the Czech Republic, moved to the front of the peloton to make sure the breakaway didn't gain too much of an advantage.
After around 80km the peloton started to begin to make inroads into the break's lead, trimming it to 6-30 with 170km remaining and 4-50 just 20km later.
The vast majority of the chasing was being done by the Czech's, clearly fancying the chances of Zdenek Stybar, although the Belgians and the Norwegians lent the occasional turn.
At the front of the race, the distance was starting to tell in the break, with Manninen the first rider to be dropped on the multiple climbs of Salmon Hill.
With just over 110km remaining, the peloton saw its first piece of action for a number of hours as Maxim Belkov (Russia) went on the attack, while at the front of the race Zhupa and Azadov were dropped from the break.
That left seven riders up the road with a two minute lead over Belkov, who himself was around 45 seconds ahead of the peloton as the race entered its final 100km.
However, with such small time gaps at the front of the race, the peloton was always going to make the catch, and as Poland joined in with the chase, the race was all brought back together with four laps and 75km remaining in the race.
That saw the starting pistol fired on the race proper, with a flurry of attacks going off the front of the main group before being brought back, Warren Barguil (France) being particularly active.
The approach to the next ascent of Salmon Hill saw Marco Haller (Austria) slip off the front. Haller was joined by Tim Wellens ( Belgium) midway up the climb, and then Lars Boom (Netherlands), Jarlinson Pantano (Colombia), David de la Cruz (Spain), Jack Haig (Australia), Odd Chrisian Eiking (Norway).
That eight-strong group quickly opened a lead of around 45 seconds, forcing Poland and France to chase on the front with three laps remaining.
The next climb of Salmon Hill saw Wellens continue to drive the pace on the front of the break, while France again attacked the front of the peloton, the gap being trimmed a little to half a minute.
The slimmed gap encouraged a counter-attack from the peloton, as Nils Politt (Germany) tried his luck, but didn't make it very far, and only served as a carrot for the peloton to target as they closed the gap to leaders.
With 32km remaining, for the first time in the race, Great Britain moved to the front as Tao Geoghegan Hart joined the chase, but Geoghegan Hart's pace wasn't enough to deter attacks, as Tom Dumoulin (Netherlands) launched a half-hearted acceleration just to test the legs.
That little move, and a brief counter-attack by Barguil, saw the gap to the leaders slimmed to just a couple of peloton by the penultimate climb of Salmon Hill. The front of the race in sight and Dumoulin went on the attack again, this time putting in much more effort.
The Dutchman didn't manage to get away, but caused significant damage in the group behind to put a few riders in difficulty. Fora brief moment there was a group of around 25 riders away, but they were brought back as four riders - Eiking, Haig, Wellens, and De la Cruz - survived out front.
Finally, with 26km remaining, the catch was made and the stage was set for a final lap showdown for the rainbow jersey.
Still looking to put on a show on home roads, the Norwegians led through the opening kilometres of the final lap, but with all of the major nations massing, Belgium in particular being visible in a long line of riders on the right-hand side of the road.
Heinrich Haussler (Australia) led the peloton up a slight ascent with 16km to go, but Sebastian Langeveld (Netherlands) and Paul Martens (Germany) were able to jump away.
That duo weren't able to open more than a couple of seconds of advantage, but the move was enough to force Belgium to the front of the peloton, as Lotto-Soudal rider Tiesj Benoot took up the chase.
Six seconds was the break's advantage with 13.5km remaining going on to Salmon Hill, but that was quickly neutralised as Cyril Gautier (France) raised the pace to set up an attack from Tony Gallopin.
However Gallopin's attack was also brought back in fairly short time, this time with Switzerland's Stefan Küng at the front. The final climb saw the big riders finally attack, with Belgium's Gilbert and Van Avermaet going after the first move.
Also in that move was Julian Alaphilippe, who then jumped straight over the top to go solo. The Frenchman quickly opened a sizeable gap, being joined by Gianni Moscon (Italy).
Those two young riders, 25 and 23 respectively, held a lead of 10 seconds over a slimmed down second group, which was failing to properly cooperate in the chase.
That allowed Vasil Kiryienka (Belarus) and Lukas Postlberger (Austria) to slip away, and briefly threaten to catch the two leaders. However seeing the two strong time triallists coming across, Alaphilippe was in no mood for hanging around and attacked again to go solo into the final five kilometres.
The Frenchman was completely committed, but was caught before the flamme rouge as the sprinters lined up for the first bunch sprints of the 2017 World Championships.
The final corner came with 300m to go, and was the launching pad for Alexander Kristoff (Norway) to go early, pulling clear of all but one rider.
That rider was Peter Sagan (Slovakia), unseen for the previous 267km, who emerged from the pack for the first time for the final sprint, first drawing alongside Kristoff, and then edging in front in the final few metres.
In the end Sagan won by half a wheel, denying Kristoff a dream home victory, as Michael Matthews (Australia) came home a distant third.
UCI Road World Championships, elite men's road race (267.5km)
1. Peter Sagan (Slovakia), in 6-28-11
2. Alexander Kristoff (Norway)
3. Michael Matthews (Australia)
4. Matteo Trentin (Italy)
5. Ben Swift (Great Britain)
6. Greg Van Avermaet (Belgium)
7. Michael Albasini (Switzerland)
8. Fernando Gaviria (Colombia)
9. Alexey Lutsenko (Kazakhstan)
10. Julian Alaphilippe (France)
Thank you for reading 20 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