The Slovakian surged ahead with less than 50 metres left and pipped local favourite Alexander Kristoff to the line. Australian Michael Matthews took third place.
"It was not easy. It came down to a sprint, that was unbelievable," said Sagan, who joined Italian Alfredo Binda, Belgians Rik van Steenbergen and Eddy Merckx, and Spain's Oscar Freire in an elite club of triple world champions.
"I'm sorry (for the Norwegian fans) but I'm happy to be world champion again."
Kristoff said he was just not fast enough in the sprint to the line.
"I did my maximum but I must be happy with the result. It's not easy to beat him," he added.
Matthews regretted that he had attacked on the last climb.
"If I could take something back I would not attack so many times on the final climb, I lost energy," he said.
It seemed that France's Julian Alaphilippe and Italian Gianni Moscon would fight it out for gold when both jumped away from the leading group 11km from the line on the ascent to Salmon Hill, a 1.4-km effort at an average gradient of 6.4 percent.
But they were eventually reined in and most of the top sprinters contested the win in front of huge, flag-waving crowds in the port city of Bergen.
Sagan, who was kicked out of the Tour de France this year for sending Mark Cavendish crashing in a sprint, was clearly the strongest as he added to his titles in Doha and Richmond, Virginia.
Belgium had no pure sprinters and they tried to blow up the race to avoid a mass finish.
Tim Wellens broke away with 70 km left and was followed by seven riders, Spain's David De La Cruz, Lars Boom of The Netherlands, Italian Alessandro De Marchi, Colombian Jarlinson Pantano, Austrian Maro Haller, Australian Jack Haig and Norway's Odd Christian Eiking.
They built up a maximum gap of 45 seconds as France tried to take control at the front of the peloton.
The break was ended 25km from the finish after the peloton was split in the penultimate passage up to Salmon Hill.
In the final ascent, Alaphilippe burst away from the leading pack and only Moscon could follow as they opened up a 10-second gap.
France was looking for a first senior road race world champion since Laurent Brochard prevailed in 1997.
They came up just short, though. The Frenchman contested the sprint but ended up 10th.
"We did everything perfectly, except that we did not win," said France coach Cyrille Guimard, who led Lucien van Impe, Bernard Hinault, Greg LeMond and Laurent Fignon to Tour de France titles in the 1970s and 1980s.
Moscon was later disqualified for taking a tow from his team car as he was trying to make his way back into the peloton after a crash.
More to come.