Boris Johnson's Brexit Bill has cleared its final parliamentary hurdle, paving the way for the UK to leave the EU with a deal in place at the end of the month.

The landmark legislation now just needs Royal Assent to be formally granted by the Queen after peers ended a tussle over the Bill on Wednesday evening.

MPs had earlier overturned amendments made by defiant peers but the unelected House of Lords bowed to the will of the Commons.

The European Union [Withdrawal Agreement] Bill will enter the statute book after assent is granted in the coming days, possibly tomorrow.

All that is left for the UK to leave with the deal in place on January 31 is for the European Parliament to give its backing to the agreement, which is likely to take place next week.

The Commons reversed five changes made by the Lords to the Bill as the legislation entered the "ping-pong" phase where it moves between the two Houses until agreement is reached.

Peers had defeated the Government on the rights of EU workers legally residing in the UK to have physical proof of their right to remain and the power of courts to depart from European Court of Justice rulings.

They also backed a move to ensure the rights of unaccompanied child refugees to be reunited with their families in the UK post-Brexit, and a proposal underlining the commitment to the so-called Sewel Convention, which states that the UK Parliament "will not normally" legislate for devolved matters without the consent of the devolved legislature affected.

However, all five amendments were comfortably reversed by MPs, with majorities ranging from 86 to 103.

With Brexit day looming, the Bill, which was passed with large majorities by MPs earlier this month, remained on course thanks to the Prime Minister's 80-strong majority.

It was up to peers to decide whether to prolong the bout of parliamentary ping-pong or bow to the will of the elected House.

Labour, Liberal Democrat and independent crossbench peers ignored repeated ministerial warnings not to amend the Bill, insisting their objection was not to stop Brexit but to ensure the legislation was better drafted.

During the debate on Wednesday, Stephen Barclay, the Brexit Secretary, said the Government could not accept the Lords amendment on citizens' rights as it would make the EU Settlement Scheme "null and void".

“This amendment would mean the successful EU Settlement Scheme in its current form would need to be abandoned. This is because there would be no need to register if people could later rely on a declaration that they were already in the UK.

"This would make null and void the 2.8 million applications and the 2.5m grants of status which have already been completed," explained Mr Barclay.

The Secretary of State said the amendment would also mean the Government would be unable to issue "more secure" digital documentation without physical documentation, adding: "This would increase the risk of fraud and raises the issue of cost to the Government and citizens."

On child refugees, Mr Barclay defended the Government's record before claiming: "Primary legislation cannot deliver the best outcomes for these children as it cannot guarantee that we 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 those negotiations."

Labour MP Yvette Cooper said: "That is what makes us all suspicious, that he wants to remove it because there's some reason why he thinks it will restrict what he wants to do and therefore that he's going to, in the end, betray the commitments that have been made to the most vulnerable children of all."

Thangam Debbonaire, the Shadow Brexit Minister, also said: "The Government's predecessor government has got form on this, promising to take 3,000 children on the Dubs scheme, as originally committed to, and taking fewer than 500 in the end."