The Labour candidate received 57% of the votes
Sadiq Khan has been confirmed as the new Mayor of London, beating the Conservative candidate Zac Goldsmith into second place.
The Labour candidate had to wait six hours after the result had become clear because of what were described as "discrepancies".
But shortly after midnight the returning officer confirmed the former Labour frontbencher as the winner on the second round of voting.
He received a total of 1,310,143 votes - 57% of the total - compared to Zac Goldsmith's 994,614, after the capital had its largest ever turnout at 45.6%
After Mr Khan took the podium, he said: "Thank you London. London is the greatest city in the world. I am so proud of our city. I am deeply humbled by the hope and trust you have placed in me today. I want every single Londoner to get the opportunities that our city gave to me and my family. The opportunities, not just to survive but to thrive."
Mr Goldsmith, who was earlier criticised for his campaign which repeatedly referenced Mr Khan sharing a platform with so-called Islamic extremists, congratulated his opponent.
Mr Khan did not mention Mr Goldsmith by name in his acceptance speech, but did make mention of negative campaigning - which some Tories have described as "dog whistle" tactics.
The new London mayor said: "This election was not without controversy and I am so proud that London has today chosen hope over fear and unity over division. I hope that we will never be offered such a stark choice again.Fear doesn't make us safer, it only makes us weaker, and the politics of fear is simply not welcome in our city."
During Mr Khan's speech after the declaration of results, Britain First candidate Paul Golding turned his back.
Mr Khan was also congratulated by his predecessor Boris Johnson, who had earlier thanked the capital for his eight years in office.
Sky's Adam Boulton said that voters in Mr Khan's constituency Tooting may now go to the polls in a by-election on June 23rd and Sky's Political Editor Faisal Islam described his victory as a "landslide" and "the biggest ever personal mandate for a British politician".
Earlier, after his victory became clear, Mr Khan received congratulations from Labour leader Jeremy Corbyn, who had otherwise had a difficult day, with the party slumping to third place in the Scottish Parliament elections.
Mr Corbyn tweeted: "Can't wait to work with you to create a London that is fair for all! #YesWeKhan.
The London Assembly, which scrutinizes the mayor, is now made up of 12 Labour seats, with the Conservatives holding eight, the Greens two, Liberal Democrats one and UKIP winning two seats - the party's first since 2004.
It meant Labour failed to win an overall majority, as they also failed to do in Wales.
Mr Khan was the bookmakers' favourite to win the mayoral race.
He is the son of a Pakistani bus driver who grew up on a council estate and took up boxing to defend himself from racists.
The former solicitor has been the MP for Tooting since 2005, and has held the posts of transport minister, shadow justice secretary and shadow minister for London.
His campaign focused largely on transport and providing affordable housing for Londoners.