Downing Street has published the legal advice it was given on Theresa May's Brexit deal by the government's top law officer, Attorney General Geoffrey Cox.

The government tried to prevent the full legal advice being published, and MPs found the government in contempt of parliament for refusing a demand to do so.

Here's everything you need to know about the legal advice the government tried to withhold.

LONDON — The government has published the full legal advice it was given on Theresa May's Brexit plan after MPs found the government to be in contempt of parliament for refusing to do so.

The advice, from Attorney General Geoffrey Cox, the country's top law officer, examines the legal effect of the proposed backstop arrangement, or Northern Ireland protocol, which is a fallback measure designed to maintain an invisible border in Ireland.

The measure is deeply unpopular among Brexit-supporting MPs because would keep the UK in the customs union and Northern Ireland even more closely aligned to the EU, as well as requiring checks on goods moving between Northern Ireland and Great Britain.

Here's what you need to know about Cox's legal advice:

Cox warns that the backstop arrangement contained within the withdrawal agreement would "endure indefinitely," a phrase which has enraged Brexiteers who say it would represent an incomplete Brexit.

It confirms the government does not have the right to withdraw from the backstop unilaterally, something Brexiteers have advocated.

There is a legal risk that the UK could become stuck in "protracted and repeating rounds of negotiations" with Brussels.

The date on the Attorney General's advice is 13 November, the same day MPs asked for the advice to be published. This could mean that the government had not actually received any formal legal advice on the Withdrawal Agreement before, despite May publishing her formal Brexit plan weeks earlier.

Labour's shadow Brexit secretary Keir Starmer said: "Having reviewed the Attorney General’s legal advice, it’s obvious why this needed to be placed in the public domain.

"All week we have heard from Government ministers that releasing this information. could harm the national interest. Nothing of the sort. All this advice reveals is the central weaknesses in the Government’s deal.

"It is unthinkable that the Government tried to keep this information from Parliament — and indeed the public — before next week’s vote."

The government had refused previous requests to publish the advice, which comes just a week before MPs vote on the deal itself, saying it would set a dangerous precedent if the Attorney General could not provide the Prime Minister with honest, confidential legal advice without fear of it being made public.

Cox instead published a 48-page legal commentary outlining the advice he had provided on the Brexit plan and was grilled by MPs in the Commons for two hours on the subject on Monday.

But MPs voted 311 to 293 to find May's government in contempt on Tuesday afternoon, forcing Downing Street to publish the advice in full. It was the first time in British parliamentary history the government has been found in contempt by MPs.