Legislation to take the UK out of the European Union on 31 January will be ratified within days, after Boris Johnson’s Brexit bill completed the final stages of its passage through parliament on Wednesday evening.

The Withdrawal Agreement Bill now requires only Royal Assent from the Queen to become law, allowing the prime minister finally to sign the Brexit deal which he struck with Brussels in October.

The European Parliament is expected to add its ratification on 29 January, allowing an orderly end to the UK’s 47-year membership of the continental bloc at 11pm on Friday next week.

Labour's Brexit spokeswoman Thangam Debbonaire described the bill's passage as "a very sad day" but Mr Johnson said it provided an opportunity to move on from the "rancour and division" caused by the Brexit process.

The PM is expected to sign the withdrawal agreement in the UK within the coming days, while European Council president Charles Michel and European Commission president Ursula von der Leyen will sign in Brussels on Friday. Once legal processes are completed, foreign secreary Dominic Raab will sign an instrument of ratification to be deposited in Brussels.

Best pictures from Final Say Brexit march Show all 76 1 /76 Best pictures from Final Say Brexit march Best pictures from Final Say Brexit march Crowds march through central London Getty Best pictures from Final Say Brexit march People's Vote Final say march - 19 October 2019 Angela Christofilou Angela Christofilou/The Independent Best pictures from Final Say Brexit march Protesters gather in Parliament Square Led By Donkeys Best pictures from Final Say Brexit march Mayor of London Sadiq Khan joins protesters PA Best pictures from Final Say Brexit march People's Vote Final say march - 19 October 2019 Angela Christofilou Angela Christofilou/The Independent Best pictures from Final Say Brexit march People's Vote Final say march - 19 October 2019 Angela Christofilou Angela Christofilou/The Independent Best pictures from Final Say Brexit march People's Vote Final say march - 19 October 2019 Angela Christofilou Angela Christofilou/The Independent Best pictures from Final Say Brexit march People's Vote Final say march - 19 October 2019 Angela Christofilou Angela Christofilou/The Independent Best pictures from Final Say Brexit march Anti-Brexit protesters fill Parliament Square in London PA Best pictures from Final Say Brexit march People's Vote Final say march - 19 October 2019 Angela Christofilou Angela Christofilou/The Independent Best pictures from Final Say Brexit march People's Vote Final say march - 19 October 2019 Angela Christofilou Angela Christofilou/The Independent Best pictures from Final Say Brexit march People's Vote Final say march - 19 October 2019 Angela Christofilou Angela Christofilou/The Independent Best pictures from Final Say Brexit march People's Vote Final say march - 19 October 2019 Angela Christofilou Angela Christofilou/The Independent Best pictures from Final Say Brexit march People's Vote Final say march - 19 October 2019 Angela Christofilou Angela Christofilou/The Independent Best pictures from Final Say Brexit march People's Vote Final say march - 19 October 2019 Angela Christofilou Angela Christofilou/The Independent Best pictures from Final Say Brexit march People's Vote Final say march - 19 October 2019 Angela Christofilou Angela Christofilou/The Independent Best pictures from Final Say Brexit march People's Vote Final say march - 19 October 2019 Angela Christofilou Angela Christofilou/The Independent Best pictures from Final Say Brexit march People's Vote Final say march - 19 October 2019 Angela Christofilou Angela Christofilou/The Independent Best pictures from Final Say Brexit march People's Vote Final say march - 19 October 2019 Angela Christofilou Angela Christofilou/The Independent Best pictures from Final Say Brexit march A demonstrator marches EPA Best pictures from Final Say Brexit march People's Vote Final say march - 19 October 2019 Angela Christofilou Angela Christofilou/The Independent Best pictures from Final Say Brexit march People's Vote Final say march - 19 October 2019 Angela Christofilou Angela Christofilou/The Independent Best pictures from Final Say Brexit march People's Vote Final say march - 19 October 2019 Angela Christofilou Angela Christofilou/The Independent Best pictures from Final Say Brexit march Protesters push a float depicting Dominic Cummings using Boris Johnson as a puppet during the Final Say Brexit march in London PA Best pictures from Final Say Brexit march EU supporters react after the result of the vote on the deal delay was announced at the House of Commons REUTERS Best pictures from Final Say Brexit march A demonstrator carries his dog draped in EU flag AP Best pictures from Final Say Brexit march Thousands of people taking part in a People's Vote march AFP/Getty Best pictures from Final Say Brexit march Protesters use their flags to shelter from the rain Getty Images Best pictures from Final Say Brexit march Protesters march towards Parliament Square Getty Images Best pictures from Final Say Brexit march Anti-Brexit demonstrators carry placards and EU flags AP Best pictures from Final Say Brexit march Sir Oliver Letwin MP in Parliament Square, London, during an an anti-Brexit, Let Us Be Heard rally, after it was announced that the Letwin amendment, which seeks to avoid a no-deal Brexit on October 31, has been accepted PA Best pictures from Final Say Brexit march Thousands of people taking part in a People's Vote march UK BROADCASTERS POOL/AFP via Get Best pictures from Final Say Brexit march A protester with "Bollocks to Brexit" stickers on his head Getty Images Best pictures from Final Say Brexit march Demonstrators march EPA Best pictures from Final Say Brexit march Britain's main opposition Labour Party shadow Secretary of State for Exiting the EU Keir Starmer, shadow Home Secretary Dianne Abbott, shadow Chancellor of the Exchequer John McDonnell, shadow Foreign Secretary Emily Thornberry speaks on stage in Parliament Square AFP via Getty Images Best pictures from Final Say Brexit march Anti-Brexit supporters cheer outside parliament AP Best pictures from Final Say Brexit march A EU supporter waves flags REUTERS Best pictures from Final Say Brexit march Anti-Brexit supporters AP Best pictures from Final Say Brexit march Protesters shout and chant demanding a final say Getty Images Best pictures from Final Say Brexit march Police look towards protesters Getty Images Best pictures from Final Say Brexit march Pro-Brexit protesters outside the Houses of Parliament in London PA Best pictures from Final Say Brexit march People taking part in an Anti-Brexit, Let Us Be Heard march head to Parliament Square in London PA Best pictures from Final Say Brexit march People taking part in an Anti-Brexit, Let Us Be Heard march in Trafalgar Square PA Best pictures from Final Say Brexit march Anti-Brexit supporters cheer outside parliament AP Best pictures from Final Say Brexit march People taking part in an Anti-Brexit, Let Us Be Heard march past Trafalgar Square PA Best pictures from Final Say Brexit march Protesters shout and chant Getty Images Best pictures from Final Say Brexit march Cory (7) sits on his father's shoulders as protesters march towards Parliament Square Getty Best pictures from Final Say Brexit march People attend the 'Together for the Final Say' march EPA Best pictures from Final Say Brexit march Protesters march towards Parliament Square Getty Images Best pictures from Final Say Brexit march Mayor of London Sadiq Khan speaks on stage PA Best pictures from Final Say Brexit march A woman in EU costume EPA Best pictures from Final Say Brexit march Anti-Brexit protesters fill Parliament Square in London PA Best pictures from Final Say Brexit march Anti-Brexit protesters AP Best pictures from Final Say Brexit march Anti-Brexit protesters hold an Independent banner Angela Christofilou/The Independent Best pictures from Final Say Brexit march Protesters hold an anti-Brexit placard by The Independent stall during the Final Say Brexit march in London Tom Richell Best pictures from Final Say Brexit march Anti-Brexit protesters in Parliament Square, London, PA Best pictures from Final Say Brexit march Demonstrators hold placards and EU flags AFP/Getty Best pictures from Final Say Brexit march An anti-Brexit protester joins in the Final Say Brexit march on 19 October AP Best pictures from Final Say Brexit march EU supporters march in London REUTERS Best pictures from Final Say Brexit march Sir Patrick Stewart and Paul McGann join in the Final Say Brexit march in London on 19 October PA Best pictures from Final Say Brexit march EU supporters march Reuters Best pictures from Final Say Brexit march A demonstrator shouts into a megaphone as she marches AFP via Getty Images Best pictures from Final Say Brexit march A dog dressed in an anti-Brexit placard is walked in the Final Say Brexit march in London EPA Best pictures from Final Say Brexit march EU supporters march REUTERS Best pictures from Final Say Brexit march A morris dancer takes part in the Final Say Brexit march in London PA Best pictures from Final Say Brexit march Whippets are dressed in EU flag clothing during the Final Say Brexit march in London AP Best pictures from Final Say Brexit march Protesters march towards parliament in the Final Say Brexit march in London on 19 October 2019 PA Best pictures from Final Say Brexit march An anti-Brexit demonstrator takes part in the Final Say Brexit march in London AFP/Getty Best pictures from Final Say Brexit march EU supporters call on the government to give Britons a vote on the final Brexit deal Reuters Best pictures from Final Say Brexit march Anti-Brexit protesters Angela Christofilou/The Independent Best pictures from Final Say Brexit march An anti-Brexit protester Angela Christofilou/The Independent Best pictures from Final Say Brexit march Anti-Brexit protesters demonstrate in London during the Final Say Brexit march on 19 October AP Best pictures from Final Say Brexit march Protesters push a float depicting Dominic Cummings using Boris Johnson as a puppet during the Final Say Brexit march in London AFP/Getty Best pictures from Final Say Brexit march Protesters march towards parliament from Park Lane in the Final Say Brexit march in London on 19 October 2019 PA Best pictures from Final Say Brexit march Marchers visit The Independent stall during the Final Say March in London Tom Richell Best pictures from Final Say Brexit march An anti-Brexit protester holds a sign calling for a Final Say during a march in London EPA

Under the terms of Mr Johnson’s deal, the UK will pay around £30 billion to the EU in settlement of its liabilities, guarantee the rights of Europeans living in Britain, create a customs border down the Irish Sea and lose all representation on the bloc’s decision-making bodies. But it will remain subject to EU rules during a transition period lasting until the end of 2020, while negotiations take place on a future partnership in areas like trade and security.

Formal withdrawal from the EU will take place next Friday despite opinion polls over more than two years - including a BMG survey for The Independent less than two weeks ago - consistently finding that a majority of voters want to remain, and despite a majority in last month's general election backing parties seeking a Final Say referendum.

The completion of the Bill’s parliamentary stages came after peers opted not to challenge Mr Johnson’s defeat of five amendments to the legislation approved by the House of Lords earlier this week - including protections for the family reunion rights of unaccompanied child migrants after Brexit.

Welcoming the breakthrough, Mr Johnson said: “Parliament has passed the Withdrawal Agreement Bill, meaning we will leave the EU on 31 January and move forwards as one United Kingdom.

“At times it felt like we would never cross the Brexit finish line, but we’ve done it.

“Now we can put the rancour and division of the past three years behind us and focus on delivering a bright, exciting future – with better hospitals and schools, safer streets and opportunity spread to every corner of our country.”

The defeat of the so-called Dubs Amendment - named after its author Lord Dubs, a wartime child refugee from the Nazis - was condemned by charities including Save the Children, who said it “puts some of the world’s most vulnerable and desperate children at even greater risk of harm”.

Mr Johnson's bill completed its parliamentary stages after just 11 days of scrutiny in the two houses, securing a 99-vote majority at third reading in the Commons earlier this month.

Its smooth passage came after a tortuous year-long wrangle at Westminster as Theresa May's version of the agreement was voted down three times, once by a historic record margin of 230 votes.

The stalemate eventually forced her resignation last July and was broken only by last month's general election, in which Mr Johnson secured an 80-seat majority, assuring him of victory in future Commons divisions and dashing remaining hopes of a confirmatory Final Say referendum on his deal.

The European Union (Withdrawal Agreement) Bill being carried between the two Houses of Parliament by the Clerk of Legislation Liam Lawrence Smyth (UK Parliament/Jessica Taylor)

Labour's shadow deputy leader in the Lords, Baroness Hayter, said that peers' changes to the bill had been swept aside by MPs in just 60 minutes.

"Number 10 has decided not to listen, whether it is to the devolved authorities, to experienced judges and senior official post-holders or to experienced members of your lordships' house," she said. "If this is to be the pattern of this administration... then I fear we are in for an unfortunate time."

As the bill left the Lords, Tory peer Patrick Cormack issued a plea for all sides of the debate to "now jettison the words, 'Brexit', 'Remain' and 'Leave'."