After 47 years as a member state the United Kingdom has formally left the European Union, finally giving effect to the result of the referendum on EU membership held in June 2016.

Thousands of people waved British flags in London's Parliament Square to mark the moment of Brexit at 11pm (midnight in Brussels).

"We are a free nation," declared one businessman who joined the crowd, which erupted into cheers as the clock ticked down.

Many pro-Europeans, including many of the 3.6 million EU citizens who made their lives in Britain, marked the occasion with solemn candlelit vigils.

Brexit has exposed deep divisions in British society. One Brexit supporter set fire to an EU flag in central London. 

Away from the celebrations, many fear the consequences of ending 47 years of ties with their nearest neighbours. Britain is the first country to leave the bloc.

It has also provoked soul-searching in the EU about its own future after losing 66 million people, a global diplomatic big-hitter and the clout of the City of London financial centre.

'Not an end, a beginning'

British Prime Minister Boris Johnson, a figurehead in the 2016 referendum vote for Brexit, acknowledged there might be "bumps in the road ahead" but said Britain could make it a "stunning success".

As he held a party in his Downing Street office, a clock projected on the walls outside counted down the minutes until Brexit.

Mr Johnson has promised to unite the island nation in a new era of prosperity, predicting a "new era of friendly cooperation" with the EU while Britain takes a greater role on the world stage.

"The most important thing to say tonight is that this is not an end but a beginning," he said in a televised address.

In a symbolic move, Mr Johnson chaired a meeting of his cabinet in Sunderland earlier today. The city was the first to back Brexit when results were announced after the referendum.

EU institutions earlier began removing red, white and blue Union flags in Brussels ahead of a divorce that German Chancellor Angela Merkel called a "sea-change" for the bloc.

French President Emmanuel Macron described it as a "historic warning sign" that should force the EU and its remaining nations of more than 440 million people to stop and reflect.

Britain's departure was sealed in an emotional vote in the EU parliament this week that ended with MEPs singing "Auld Lang Syne", a traditional Scottish song of farewell.

But almost nothing will change straight away, because of an 11-month transition period negotiated as part of the exit deal.

Britons will be able to work in and trade freely with EU nations until 31 December, and vice versa, although the UK will no longer be represented in the bloc's institutions.

But legally, Britain is out.

And while the divorce terms have been agreed, Britain must still strike a deal on future relations with the EU, its largest trading partner. 

Both will set out their negotiating positions Monday.

"We want to have the best possible relationship with the United Kingdom, but it will never be as good as membership," European Commission president Ursula von der Leyen said in Brussels.

The pro-Brexit group Leave Means Leave held a rally in London to celebrate Britain's departure from the bloc.

Read more:
The UK's rocky road to Brexit
Brexit - What changes and what stays the same?

In Scotland, which recorded the biggest Remain vote, First Minster Nicola Sturgeon led a protest march in Edinburgh, with a candlelit vigil outside the Scottish Parliament.

In a post on Twitter, she said that Scotland will return to the EU as an "independent country".

Meanwhile, anti-Brexit protesters held demonstrations along the border.

Members of Border Communities Against Brexit said they were demonstrating against Northern Ireland being taken out of the EU against its will.

They said they wanted to fight for the rights of workers and citizens who live along the border.

BCAB Chair Declan Fearon said they wanted to highlight that they are losing a lot of their previously held European rights.

Next Brexit phase essential for economy - Taoiseach

Taoiseach Leo Varadkar has said people will wake up tomorrow when the UK has departed the EU with no hard border and citizen rights are protected.

"It didn't have to be that way. We could have been heading into something very different," he said.

Speaking on RTÉ's Morning Ireland, he said the next phase is essential for the economy and getting a good trade deal.

Tánaiste and Minister for Foreign Affairs Simon Coveney has said the fundamental change that we are now preparing for in the context of the relationship between Ireland and Britain is from a trade perspective.

He said the second half of the Brexit negotiations will be "challenging" and Dublin Port is ready to deal with customs checks but he said there is a potential for chaos In terms of traffic and log jams if the new systems do not work.

Additional reporting Sean Whelan, Tony Connelly, Gail Conway, PA