The Lib Dems poured resources into the contest as they successfully switched the focus of the campaign to Brexit in the staunchly Remain west London seat after Mr Goldsmith quit as a Tory MP to force the by-election so he could run as an anti-Heathrow expansion independent.

The result saw Ms Olney poll 20,510 votes to Mr Goldsmith’s 18,638, on a turnout of 41,367, or 53.6%. The 21.74% swing to the Lib Dems from Mr Goldsmith topped the 19.3% swing they achieved from the Tories in the Witney byelection.

It is one of the biggest upsets since George Galloway took Bradford West from Labour in 2912 after he was ousted from the party in 2003. From finishing fifth in the 2010 general election, Galloway’s Respect party achieved a 36.59% swing.

Today’s Lib Dem victor, who took 49.7% of the vote, said the outcome had sent a “shockwave” through Downing Street and paved the way for Parliament to “override” the EU withdrawal referendum result.

How the voting went

“It does look now as if we can have a vote in Parliament that might override the referendum. And I will, obviously, be voting to Remain because that is always what I have believed,” she told Sky News.

Asked if she would actively resist Brexit as an MP, she said: “Absolutely. Now I’ve been given this mandate.”

Ms Olney said the dramatic victory was a rejection of the “Ukip vision” of Britain, and the politics of “anger and division”.

In her victory speech the Lib Dem said: “The people of Richmond Park and North Kingston have sent a shockwave through this Conservative Brexit government, and our message is clear: we do not want a hard Brexit. We do not want to be pulled out of the single market, and we will not let intolerance, division and fear win.”

In a brief acknowledgement of the result, a clearly downcast Mr Goldsmith said: “This by-election that we have just had was not a political calculation, it was a promise that I made and it was a promise that I kept.”

Labour’s Christian Wolmar lost his deposit as he trailed a distant third with 1,515 votes, after the Greens backed the Lib Dem candidate, while Ukip stood aside to give Mr Goldsmith a clear run, and the Tories did not field a standard bearer.

A Conservative Party spokesman said the result would make no difference to Brexit plans, stating: “This result doesn’t change anything. The Government remains committed to leaving the European Union and triggering Article 50 by the end of March next year.

“In addition, we will continue to take decisive action in the national interest to secure the UK’s place the world - supporting a third runway at Heathrow to secure jobs and business opportunities for the next decade and beyond.

“Commiserations to Zac Goldsmith on his defeat. We are sorry that he is no longer in the House of Commons.”

Lib Dem leader Tim Farron said: “The message is clear: The Liberal Democrats are back and we are carrying the torch for all of those who want a real opposition to this Conservative Brexit government.

“This was a remarkable, come-from-nowhere upset that will terrify the Conservatives. A year and a half ago, their man won by nearly 40% and had a majority of more than 20,000. In one fell swoop we have wiped that out completely.

“If this was a general election, this swing would mean the Conservatives would lose dozens of seats to the Liberal Democrats - and their majority with it.

Ms Olney said victory seemed a possibility only in the final stages of the campaign, saying: “We didn’t expect until very late on to actually win.”

Pressed on the first things she will begin working on as an MP, she said: “Brexit and Heathrow were the two key things we fought this campaign on, so those are the two priorities when I get into Parliament.”

Mr Wolmar said voters had disliked Mr Goldsmith’s “ghastly, disgusting” bid to be London mayor in which Labour accused him of running a racist campaign against Sadiq Khan.

Mr Farron said that a third of Conservative Leave voters had switched to the Lib Dems in the by-election.

He told BBC Radio 4’s Today programme: “If I tell you that nearly a third of Tory voters from the last election who voted Leave in June voted Liberal Democrat yesterday you will see that this is not just about Remain versus Leave rerun, it’s about people trying to say to Theresa May we do not like the extreme version of Brexit outside the single market you are taking us down.”

Speaking at Chatham House, Foreign Secretary Boris Johnson said he was “sad” that Mr Goldsmith would no longer be in the House of Commons, where he “made a remarkable contribution”.

He added: “He was heroic and principled in standing up for what he believes in on Heathrow expansion.

“He will be missed but he will certainly be back.”

Spoilt little rich kid playing games with the voters, or big, principled eco-warrior standing up for what he believed in, Mr Goldsmith has always sharply divided opinion.

Born Frank Zacharias Robin Goldsmith to parents Sir James and Lady Annabel who were as rich as they were glamorous, the future MP was expelled from Eton at 16 after marijuana was found in his room. He claimed the drugs belonged to someone else, and later recalled: “Amazingly, at that one particular moment in my Eton career, I was innocent.”

Whether he was innocent or not back then, in his doomed bid to become London mayor Labour branded the 41-year-old guilty of running a racist campaign against Sadiq Khan.

Even his high-profile sister Jemima distanced herself from Mr Goldsmith, tweeting: “Sad that Zac’s campaign did not reflect who I know him to be - an eco friendly, independent-minded politician with integrity.”

And senior Tories also turned on him for the tone of his attacks on Mr Khan, with former Cabinet member Baroness Warsi condemning the “appalling dog whistle campaign”, and the Conservative leader on the the Greater London Assembly, Andrew Boff, saying it had “done real damage” and “blown up” bridges built with Muslim communities.

Mr Goldsmith strongly denied the charges, but Mr Khan had the last word, burying his opponent under a landslide victory.