The government will be forced to publish the full legal advice on the final Brexit deal after it was defeated in the Commons by Labour, backed by the DUP.

Ministers conceded defeat by ordering Conservative MPs to abstain in a Commons vote, after it became clear they would lose any attempt to stop the disclosure when the DUP said it would support the move..

Ministers will now be required to to publish the advice covering the legally binding withdrawal agreement, including the Irish backstop plan, before any Brexit deal is put before parliament.

The shadow Brexit secretary, Keir Starmer, used the arcane procedure of a “humble address”, which the party has used previously to force the release of Brexit impact assessments.

During a debate in the Commons, the Cabinet Office minister, David Lidington, offered a last-ditch compromise of publishing legal analysis of the deal, but stopped short of committing to distributing the full legal advice.

Lidington said it was a “perfectly fair request” that MPs should know the legal implications of the withdrawal agreement before a vote. He promised that MPs would be provided with “detailed legal analysis of the meaning and implications of the agreement” and said the attorney general, Geoffrey Cox, would take questions in the Commons.

However, Labour refused to accept the compromise and the Tory whips then instructed MPs to abstain, rather than risk a humiliating defeat. The motion was passed without a vote.

During the debate, some MPs expressed concern about the scope of the motion. Lidington said that to publish all legal advice to date would mean the publication of “at a conservative estimate, upwards of 5,000 different pieces of documentation”.

Starmer underlined that Labour was requesting “the final advice provided by the attorney general to cabinet concerning the terms of any withdrawal agreement”.

He said it should be made available to all MPs after any withdrawal agreement is reached with the EU but before MPs are asked to vote on the deal. “We are not calling for the legal advice to be published in its draft form or as it is given, on a rolling basis,” he said.

A Labour source confirmed the party would not push for any further disclosures of past legal advice, even if they would technically be covered under the terms of the Labour motion.

The wording of Lidington’s compromise offer was strikingly similar to an amendment tabled by a group of hard Brexiter Tories, including Robert Courts and Jacob Rees-Mogg. That amendment had been rejected for debate by the Commons Speaker, John Bercow.

During the debate, Courts quipped that Lidington’s offer sounded “very similar” to the compromise amendment in his name. The group had said it would abstain on the motion should its amendment be rejected, another sign the government would be defeated if Tories were whipped to vote against the Labour motion.

The former Tory minister Anna Soubry, a prominent pro-remain MP, angrily asked why MPs had been instructed to abstain, saying: “Who is running this country – the government or the ERG?”

Prominent Tory remainers appeared sceptical of the Labour proposal in their interventions in the debate. Dominic Grieve, the former attorney general who led rebel efforts to force a “meaningful vote” on the final deal, said he had “great sympathy with the anxieties” but said the proper practice would be government publication of the legal position after the negotiations were concluded.

“And if that differs from what the attorney general has advised, I’d expect the attorney general to resign forthwith,” he said.

The DUP had said it would instruct its MPs to vote with Labour. The Tories rely on votes from the Northern Irish party in order to command a majority.

The DUP Brexit spokesman, Sammy Wilson, said: “If we’re going to make a decision on this it’s a most important decision, then we should know the full implications.

“It should be spelled out to the public, the people of Northern Ireland and the people of the UK should know, is the government binding you to an arrangement which will be impossible to get out of collectively or just for the people of Northern Ireland?”