The contest to succeed Boris Johnson became increasingly divisive in the run up to the vote, with Goldsmith questioning Khan’s links to "extremists", and Labour claiming the Tories were running an "Islamophobic" campaign.
But ultimately Khan prevailed, and has won City Hall back for Labour after eight years of the Tories ruling the capital.
Story continues below...
Labour leader Jeremy Corbyn tweeted his congratulations:
As did Tory cabinet minister Sajid Javid:
Even before the result was announced Tories lined up to criticise Goldsmith's campaign.
Conservative Sayeeda Warsi slammed her own party's campaign in a tweet and Goldsmith's own sister also appeared to criticise it:
Former David Cameron advisor Steve Hilton also issued a damning verdict, accusing the Tories of bringing back the 'nasty party' label.
After the polls closed on Thursday, Boff revealed he had spoken to Goldsmith and said it was “a mistake” to attack Khan with such allegations over extremism links, as it undermined the party’s hard work in appealing to the Muslim community.
Speaking on BBC’s Newsnight, he said: "I don’t think it was dog whistle, because you can’t hear a dog whistle. Everybody could hear this.
"It was effectively saying that people of conservative religious views are not to be trusted and you shouldn’t share a platform with them and that’s outrageous.”
"I was really troubled by one particular aspect [of the campaign] and that’s when he started equating people with conservative religious views with sympathising with terrorism. That sent a message out to many of the communities in London that’s very difficult to justify."
Story continues below...
During the campaign, Khan told the HuffPost UK he felt his rival’s negative campaign was putting ethnic minorities off taking part in politics.
He said: “How do you think they feel when – and I say this without hubris or arrogance – a mainstream British Muslim, someone who has spent his life lecturing British Muslims about getting involved in mainstream society and civic society is treated this way?
"I’ve already had people approaching me saying ‘you know, do you really think I’m going to encourage my nephew and niece, son and daughter, to get involved in politics if this is the way that you’re treated?’
"That’s why I’m disappointed in Zac. Zac should know better and Zac does know better and one of the things when you’re a candidate is you receive advice all the time."
Khan also spoke in April about how the "Donald Trump approach" to politics would never succeed in London.
"Trying to divide communities, turn them against each other – I don’t think will work in London," he said.
"We don’t just tolerate differences, we respect them. My campaign has Muslims, Jews, Christians, Buddhists, Sikhs, those who aren’t a member of an organised faith, rich, poor, old, young, black, white, gay, lesbian. We’ve even got Yorkshiremen and women helping on my campaign, that’s how inclusive we are. And that’s the London I know."
Khan's historic victory was duly hailed as a "triumph" for the capital.
The victory for Khan gives a rare piece of good news to Labour, who suffered a poor night in other elections across the UK.
The party has been pushed into third place in the Scottish Parliament after finishing behind the SNP and the Tories, and will have to rule as a minority administration in Wales after losing a seat in the Assembly.
Labour also lost council seats in England, at a time in the electoral cycle when opposition parties are expected to make gains.