The four-time Olympic champion looked out of contention in the final lap but found space where none seemed to exist to beat Germany's Maximilian Levy in a photo finish.
The victory, which followed a win in the London World Cup earlier this year, will surely now guarantee his Olympic place in the event this summer.
It might also make selectors life easier, perhaps focusing Hoy on the team sprint and keirin and young pretender Jason Kenny on the team sprint and sprint, following his win over Hoy in the semi-finals of that event yesterday.
This was Hoy's 11th career world title and his third victory in the keirin, following successes in 2008 and 2010.
And it underlined that when it comes to pure acceleration, tactical nous and superior bike handling skills, the 36-year-old is still the best there is.
New Zealand's Simon van Velthooven initally took bronze while Great Britain's Kenny, silver medallist in the sprint, settled for fourth, although he was later upgraded to the podium following the Kiwi's disqualification.
"I'm shocked it was an unbelievable race and I certainly left it late but I'm just so happy to be a world champion again," said Hoy.
"I wouldn't have put money on me with half a lap to go, I'd written it off but I breathed in, shut my eyes and went through the gap.
"However, I've shown my rivals that I have other strings to my bow with my tactics but Max will be incredibly tough to beat in London."
And Ben Swift and Geraint Thomas combined to win silver in the madison, won by Belgium.
Britain conclude the championships with five golds in the 10 Olympic events - in addition to Hoy's keirin victory there were successes in the men's and women's team pursuit and golds for Laura Trott in the omnium and Victoria Pendelton in the sprint.