“We’re going to win it,” one of Sadiq Khan's closest aides told me on Wednesday. But others in Labour were sharply divided over who would achieve the party's London mayoral nomination. Tessa Jowell's camp continued to express sincere confidence until the end. The former culture secretary had long been regarded as the frontrunner and was said by her team to be performing well among all three sections of the Labour selectorate. Her supporters hoped that her public profile, Olympics role and positive "One London" campaign would deliver her victory.

But the final result wasn't just a Khan win but a Khan landslide. The former shadow justice secretary and shadow London minister, who managed Ed Miliband's leadership campaign in 2010, won by 59 per cent to Jowell's 41 per cent. The Tooting MP's strengths had long been known. He won the endorsement of major trade unions, including Unite, the GMB and the CWU, giving him a formidable advantage among this group. But unlike Miliband in 2010, Khan didn't just win among affiliated supporters but among party members. How did he do it?

In recent months, Labour's electorate has changed beyond recognition as thousands of left-wingers have joined to vote for Jeremy Corbyn in the leadership contest. The Corbynites were hugely receptive to Khan's candidacy: he opposed the Iraq war (unlike Jowell), voted against the welfare reform bill and nominated the backbencher for the leadership. Khan's comprehensive victory points to a clear win for the left-winger tomorrow.

But it was also the mayoral candidate himself who, in the words of one aide, "changed the electorate". With Labour's new one-member-one-vote system in mind, Khan went on more than 200 visits to workplaces, community centres, churches, temples, mosques and shopping malls to attract new supporters. A dedicated "recruitment team" of 10 staff and dozens of volunteers was deployed to raise interest in the process. A source described this as in "stark contrast to the other mayoral campaigns which focused exclusively on the existing members". By the end, there were nearly three times as many Labour members and supporters in London as at the general election (114,00 to 41,000 on 7 May). It is the new group of £3 registered supporters who account for Khan's landslide: he won 17,179 to Jowell's 6,351, compensating for a far closer race among members (24,983 to 24,019) and a narrower result among affiliates (5,990 to 3,203), who represented just 11 per cent of the electorate.

It was also Khan who won the most support from Labour MPs (16), Khan who had the backing of Ken Livingstone and his former opponent Oona King, and Khan who had by far the biggest volunteer and field operation. When all of these strengths are taken into account, the scale of his victory is no longer surprising. "Sadiq mobilises," an aide said. After the result was announced, Khan told me that, unlike others, he never doubted he would win comfortably: "I never thought it was going to be a close race. I was always quietly confident, I've done 200 visits since 14 May: bus garages, churches, synagogues, factories, local shopping centres. Speaking to and listening to Londoners ... I always knew, irrespective of what respectable London newspapers may write and who they're going to endorse, when it comes to voters seeing what the candidates stand for and what their vision is that I'd win."

Khan's chief opponent in next May's election will almost certainly be the Conservative Zac Goldsmith. London is a Labour city - the party won 45 of its 73 seats and 44 per cent of the vote at the general election. But on just one occasion since the mayoralty was established (2004) has the party's candidate won. Khan can take nothing for granted. Should Corbyn become rapidly unpopular as Labour leader, as many in the party expect, he could suffer collateral damage. But few doubt that he has a serious chance of winning. Were this Muslim son of a bus driver, and council estate boy, to become London mayor it would be an immensely powerful symbol of the capital's diversity and a triumph of social mobility.