The bill was approved by Parliament's upper chamber after the House of Commons overturned changes to the government's flagship Brexit bill made a day earlier by the unelected House of Lords.
The bill will become law when it receives royal assent from Queen Elizabeth II, a formality that could come as soon as Thursday.
Britain is scheduled to leave the European Union on Jan. 31, more than three and a half years after voters opted for Brexit in a June 2016 referendum, and after many rounds of political wrangling.
"Ät times it felt like we would never cross the Brexit finish line, but we've done it," Prime Minister Boris Johnson said.
The Lords voted Tuesday to demand that post-Brexit Britain continues to let unaccompanied migrant children in EU countries join relatives living in the U.K. The promise was made in 2018 by former British Prime Minister Theresa May, but it was removed from the Brexit legislation after Johnson's Conservatives won a big parliamentary majority in an election last month.
Johnson's government says it intends to continue resettling child migrants in Britain after the country leaves the EU but argues that the issue does not belong in the EU withdrawal bill, which sets out the terms of Britain's departure from the 28-nation bloc.
Brexit Secretary Stephen Barclay said an agreement on taking in the children "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."
But Labour lawmaker Yvette Cooper accused Johnson's Conservative government of planning to "betray the commitments that have been made to the most vulnerable children of all."
The House of Commons also stripped out changes made by the Lords to bolster the rights of EU citizens in Britain, protect the powers of U.K. courts and ensure a say for Scotland and Wales in post-Brexit legal changes.
The wrangling didn't stop the Brexit bill from becoming law, because the House of Commons can override the unelected Lords.
Members of the Lords acknowledged Wednesday that they would have to give way.
"We are at the end of a very long road," said Martin Callanan, a Conservative Brexit minister in the Lords.
The EU parliament also must approve the Brexit divorce deal before Jan. 31. A vote by the European Parliament is expected next week.
Despite Johnson's repeated promise to "get Brexit done" on Jan. 31, the departure will only mark the start of the first stage of the country's EU exit. Britain and the EU will then launch into negotiations on their future ties, racing to strike new relationships for trade, security and a host of other areas by the end of 2020.