The British government suffered a major blow as it lost a parliamentary vote on legal advice it received on the Brexit deal agreed with EU leaders last month.

A motion by the main opposition Labour Party to find the government in contempt of parliament for failing to publish the advice was passed by 311 MPs in favour to 293 against.

It came as Brexit firebrand Nigel Farage said he was leaving the UK Independence Party, which he used to lead and turned into an influential force in British politics.

“With a heavy heart, I am leaving UKIP. It is not the Brexit party our nation so badly needs,” Farage wrote in a column for the Daily Telegraph.

The government reacted to the defeat by saying it would published the “final and full” advice tomorrow.

Opponents believe the advice will reveal Attorney-General Geoffrey Cox’s misgivings about the Brexit agreement.

The vote has little direct impact on the Brexit debate, but reflects mounting tension between the government and parliament over the next steps in Brexit.

Labour’s Brexit spokesman Keir Starmer said: “This House has now spoken and it’s of huge constitutional and political significance. It is, I think unprecedented for this House to find government ministers in contempt”.

Parliament is set to begin debating the divorce deal agreed between the government and the European Union, before a vote on December 11.