LONDON                -          Britain’s departure from the European Union was set in law Wednesday as London returned a signed treaty and MEPs prepared to vote to ratify the divorce.

After half a century of sometimes awkward membership, the United Kingdom will leave the EU at midnight Brussels time on Friday. The day began with Britain’s permanent representative Tim Barrow -- from Saturday to be its ambassador to the EU -- handing back the withdrawal agreement.

This had already been inked by Brussels’ top figures and been sent to London for Prime Minister Boris Johnson to sign for the UK government. “This step ensures that the UK has fulfilled its legal obligations regarding our exit from the EU,” the British mission said. Nigel Farage, veteran MEP and leader of Britain’s Brexit Party, was in triumphant mood after two decades as a thorn in Brussels’ side. But there were tears -- and some nostalgic singing -- at farewell meetings between pro-European British MEPs and their European parties.

Farage said he had loved playing the “pantomime villain” in the Strasbourg assembly, feeding opposition to Europe at home with theatrical YouTube clips. But he insisted on the seriousness of Brexit, comparing its significance to king Henry VIII taking Britain out of the Catholic church in 1534. “He took us out of the Church of Rome, and we are leaving the Treaty of Rome,” he said, referring to the EU’s 1957 founding document.

Later in the day, Farage’s fellow MEPs were to gather for a historic vote to incorporate the withdrawal agreement into EU law. This will be the last legislative act of the 73 remaining British MEPs. Departure will be hard for some.

Iratxe Garcia Perez, the Spanish leader of the Socialist group, choked back tears as she said farewell to her British Labour Party comrades.

And parliamentary speaker David Sassoli reached for a historical metaphor of more recent date than that deployed by Farage. “It’s a sad day for our parliament, not just for our political family, but our generation has seen walls fall,” he said.

The Scottish National Party promised to add to the drama by playing their MEPs out with bagpipes, and liberals sang “Auld Lang Syne” together.

After Brexit the United Kingdom will be what the EU calls a “third country”, outside the union, but the political and economic drama will continue. Britain and Europe will apply EU rules on trade and free movement of citizens until the end of the year, while negotiating a free trade agreement. In the face of scepticism in EU capitals, Johnson insists he is optimistic that a comprehensive free trade deal can be done before the next cliff-edge.

Fishing rights, residency and working rights for citizens, tariff free trade, access to Europe for Britain’s huge services sector: all will be on the table. “Brexit is a loss for us all,” European Commission Vice President MarosSefcovic said Tuesday.

He said it was important for the EU “to maintain our unity” as Europe negotiates the future partnership with the UK. The British minister for Europe attending the meeting, Christopher Pincher, expressed optimism on what the talks would yield. “We’re looking forward to a very different world and a very different relationship,” he told reporters on Tuesday.

Farage will leave Brussels on Wednesday but the other Brexit Party MEPs will march out of the parliament on Friday morning with the Union Jack in hand. They will join their leader in London at a Brexit party, before the houses of parliament.