Pro-EU candidate Sarah Olney on Friday won a parliamentary by-election in the posh London suburb of Richmond, ousting the pro-Brexit incumbent Zac Goldsmith in what will be seen as a blow for the British government.

The Liberal Democrat candidate took 49.68 percent of the votes while runner-up Goldsmith had 45.15 percent, according to figures announced by local mayor David Linnette.

The poll had been widely seen as a mini-referendum on Brexit in a pro-European Union heartland, with locals turning out to support the Lib Dem centrist party that wants a second referendum on EU membership.

Following her victory, Olney vowed to fight against Brexit in parliament.

"There's been a leave vote in the referendum, but I still passionately believe that remaining in the EU is best for Britain," she told Sky News television.

The Richmond election was sparked when Goldsmith quit as an MP in the ruling Conservative Party after the government backed expanding the nearby Heathrow Airport, vowing to stand for re-election as an independent.

"This by-election that we just had was not a political calculation, it was a promise that I made and it was a promise that I kept," he said after the results.

Following his resignation from the Conservatives the party announced it would not put forward a candidate to challenge the Richmond seat.

The Conservatives expressed "commiserations" for Goldsmith and described him as a "popular figure" within the party.

"We are sorry that he is no longer in the House of Commons," the party said in a statement.

The race left six other candidates falling far behind Olney and Goldsmith, in a by-election which saw 41,367 votes cast with turnout at 53.6 percent.

New MP vows to oppose Brexit

Olney, 39, is a newcomer to politics -- an accountant who joined the Lib Dems only in May 2015.

In the June referendum on EU membership, 52 percent nationwide voted to leave, but in Richmond, a well-heeled borough in southwest London, 69 percent voted to remain in the bloc.

Its 82-percent referendum turnout, one of the highest in the UK, showed it was an issue locals felt passionate about.

The British government is currently preparing for the EU divorce and Prime Minister Theresa May has promised to start formal exit proceedings by the end of March.

But her plans face a legal challenge, after the High Court of England and Wales ruled last month that the premier does not have the power to invoke Article 50 of the European Union's Lisbon Treaty which would kick-start Brexit.

The government has appealed the ruling and Britain's Supreme Court will on Monday begin hearing arguments with a decision due in the New Year.

Olney said if the government loses and invoking Article 50 is put to a parliamentary vote, she will vote against it.

"That's been a central part of my campaign and now I've been given a very clear mandate that that's what they (constituents) want me to do," she told BBC News television following the results.

But the Conservative Party was quick to dismiss Olney's view, 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," said the party's statement.