The historic moment, which happened at 23:00 GMT, was marked by both celebrations and anti-Brexit protests.Candlelit vigils were held in Scotland, which voted to stay in the EU, while Brexiteers partied in London's Parliament Square.
Boris Johnson has vowed to bring the country together and "take us forward".
In a message released on social media an hour before the UK's departure, the prime minister said: "For many people this is an astonishing moment of hope, a moment they thought would never come.
"And there are many of course who feel a sense of anxiety and loss.
"And then of course there is a third group - perhaps the biggest - who had started to worry that the whole political wrangle would never come to an end.
"I understand all those feelings and our job as the government - my job - is to bring this country together now and take us forward."
He said that "for all its strengths and for all its admirable qualities, the EU has evolved over 50 years in a direction that no longer suits this country".
"The most important thing to say tonight is that this is not an end but a beginning," he said, and "a moment of real national renewal and change".