Boris Johnson’s Brexit bill has cleared its last hurdle after the government overturned five House of Lords amendments to it, including one that would have restored the right of unaccompanied child refugees to be reunited with their families in the UK.

The legislation is expected to gain royal assent within days after peers agreed to end the parliamentary “ping-pong” phase where it moves between the two houses until agreement is reached.

While the passage of the withdrawal agreement bill (Wab), which puts the deal into legislation, became a formality after Johnson won a significant majority in December’s election, it is nonetheless a symbolically significant moment after Theresa May’s plan was rejected by MPs three times.

In a brief comment calling for an end to “rancour and division”, Johnson said: “At times it felt like we would never cross the Brexit finish line, but we’ve done it.”

There was, however, some final controversy, as opposition MPs condemned the government for ordering Conservative MPs to oppose an amendment drafted by Alf Dubs, the Labour peer and former child refugee, guaranteeing family reunion rights. Lord Dubs called the move “bitterly disappointing”.

The amendment, passed in the Lords on Tuesday, was rejected in the Commons by 342 votes to 254. All those who voted against were Conservatives.

“What could be more humane than asking that unaccompanied child refugees stranded in Europe be able to join relatives in this country?” Dubs said in a tweet.

It was among five amendments to the EU withdrawal agreement bill passed by peers which have now been overturned. The bill puts the government’s Brexit deal into law.

There were also amendments on EU workers legally residing in the UK getting physical proof of their right to remain; a commitment to the UK parliament not legislating for devolved matters without the consent of the devolved legislature affected; and two relating to the power of courts to depart from European court of justice rulings.

Labour’s Diane Abbott, the shadow home secretary, said the government was “attempting to shirk its moral and legal obligation to child refugees and their families”.

She said: “The Tory manifesto just a month ago claimed they would continue to support refugees, and even that they would increase that support. This is a shameful betrayal of those promises.”

Stuart McDonald, the SNP’s immigration spokesperson, said: “Rather than stepping up and playing its role in addressing the refugee crisis, the toxic Tory government has instead lurched to the extremes and closed the door on some of the most vulnerable children in the world.”

Dubs, who came to the UK as a Kindertransport child refugee after fleeing Prague in 1939, has urged the government to enshrine, after Brexit, the principle of family reunion for child refugees fleeing conflict .

Responding later in the Lords, Dubs said he noted government promises to make a statement on the issue in the next couple of months, saying ministers should explain how they would make sure the system was ready for the start of 2021, when the Brexit transition period ends.

While the measure was originally in the bill, it was removed after December’s election victory for Boris Johnson, with the government insisting it would stick to the commitment but did not see the need to put it into a Brexit bill.

“The government’s policy is unchanged. Delivering on it will not require legislation,” the Brexit secretary, Stephen Barclay, told MPs as he explained to the Commons why ministers opposed the amendment.

“Primary legislation cannot deliver the best outcomes for these children as it cannot guarantee that we will reach an agreement. And that is why this is ultimately a matter which must be negotiated with the EU, and the government is committed to seeking the best possible outcome in these negotiations.”

Barclay came under pressure from MPs to explain his reasoning. Yvette Cooper, the Labour former chair of the home affairs committee, said she did not understand the active decision to remove the measure from the bill.

“There’s loads of things in legislation through the decades that the government says it agrees with and so it says it’s not needed, but it doesn’t remove it from the statute book,” she said. “And that is what makes us all suspicious.”

Barclay replied: “The reason is the purpose of this legislation is to implement in domestic law the international agreement we’ve reached.”