Adazzling Friday morning in May 2023: the limousine pulls into Downing Street and out steps a diminutive figure, fresh from kissing hands at the palace. He approaches the lectern, ready to tell the nation of his vision for the next five years, and reflects on the path that has led him to the top job.

It had been a gamble, and one that might have gone disastrously wrong. When Theresa May resigned after Britain formally left the EU on 29 March 2019, he had made up his mind – against the strong advice of some of his aides – not to seek a second term as London mayor but to return, if possible, to the Commons.

The new Tory leader, he calculated, would be forced by public exasperation to go to the country sooner rather than later. He also reckoned that Jeremy Corbyn would not win, the air having leaked from his bubble since the high point of summer 2017.

So it proved. Amber Rudd, May’s successor, secured a small majority for the Conservatives in the election of 2020. Corbyn quickly stood down to spend more time with his allotment – plunging Labour into its most rancorous leadership contest in living memory. The advantage in that conflict had been the man’s relative freedom from faction: he was neither the candidate of Momentum, the left-wing movement, nor of Progress, its closest Blairite equivalent.

Instead, he ran on his record in London and the strength of his public profile – and won. And now he had won again, this time in the greatest race of them all. Step forward, Prime Minister Sadiq Khan.

The precise timing and the identity of the Tory leader he might face when the time comes are a matter of speculation. Khan, who was first elected mayor in 2016, may yet hold on for a second term in City Hall, calculating that the context will be more propitious in 2024. But the core of the plan – a return to the Commons and a run at the top job – is not in doubt. Everything else is detail.

Born in 1970 to a British Pakistani bus driver and seamstress, Khan was a solicitor before his election as MP for Tooting in 2005. Though he achieved the rank of minister of state for transport under Gordon Brown, he was rarely cited as a superstar-in-waiting. After Brown’s departure in 2010, he ran Ed Miliband’s leadership campaign and went on to serve him as shadow secretary of state for justice, shadow lord chancellor and shadow minister for London.

Again, he was not generally thought to be in the first rank of Labour politicians. When the succession was discussed, it was Yvette Cooper, Andy Burnham and Chuka Umunna whose names were routinely mentioned.

Khan’s stroke of political genius was to see that the mayoralty offered him an alternative – and more effective – way of making his mark on the national stage. Better to run London with panache than to plod along as a little-known member of the shadow cabinet.

Adopted as Labour’s nominee for mayor in September 2015, he defeated the Tories’ candidate, Zac Goldsmith, the following May, after a campaign in which the Conservatives’ ugly insinuation that Khan was associated with Muslim extremists backfired badly.

From the start, he flourished in his new metropolitan role, grasping instinctively that success in municipal office depended upon practical success rather than ideological warfare. He quickly introduced the one-hour Hopper bus fare and made progress on the Night Tube. Measures against air pollution were high on his agenda, notably the Ultra-Low Emissions Zone (ULEZ), which will be introduced next year. On housing, he has relaxed the planning rules governing London’s 13 outer suburbs as part of a broader strategy to build 650,000 new houses by 2029.

With the excellent Patrick Hennessy guiding his communications, the mayor has also developed a flair for the theatrical -flourish. In September last year, his personal approval ratings soared after Transport For London refused to renew Uber’s licence, citing its “lack of corporate responsibility” over the reporting of criminal offences, medical certificates and driver background checks. For the first time, a senior British politician was taking on a tech giant, a consumerist David waving a fist at a cyber-Goliath. Londoners lapped it up.

Distancing himself from Corbyn’s grand national project, Khan has instead focused on the needs of his city: he is as likely to be seen at the opening of an East End market as the first night of a play at the new Bridge Theatre. His responses to the multiple terrorist incidents in London since he became Mayor have been poised and statesmanlike.

Like a US state governor preparing a run at the presidency, he has made his case for a bigger job through local action rather than speechifying and faction-fighting. His long-term strategy depends upon Labour growing weary of ideological struggle and looking for a leader hardened by practical experience.

And his greatest ally in this plan? None other than Donald Trump. Every time the president or a member of his family tweets disobligingly about Khan – which is often – his prospects of eventual glory increase.

To have the world’s most powerful man attacking you as crudely as Trump has the mayor (sneering, for instance, at his “pathetic excuse” after the London Bridge terror attacks) is a gift to a Labour politician. It has made his name globally. It may yet ease his path to Number Ten, and – who knows? – a surreal meeting in the Oval Office with the man who did so much to make it possible.

Read more:

Jeremy Corbyn interview: 'As far as I know, my team voted Remain. I haven’t asked them'

London is the greatest city in the world

Sadiq Khan: this man stands for London