A disappointed David Cameron as resigned as Prime Minister after Britain voted to leave the European Union.
Mr Cameron made the announcement in a statement outside Downing Street after the final result was announced.
The resignation takes effect in October.
Cameron said he would attempt to “steady the ship” over the coming weeks and months.
He had urged the country to vote Remain, warning of economic and security consequences of an exit, but Leave won by 52% to 48%.
“I’m very proud and very honoured to have been prime minister of this country for six years,” he said.
England and Wales voted strongly for Brexit, while London, Scotland and Northern Ireland backed staying in.
UKIP leader Nigel Farage hailed it as the UK’s “independence day” but the Remain camp called it a “catastrophe”.
The pound fell to its lowest level against the dollar since 1985 as the markets reacted to the results.
Turnout for the referendum was 71.8% – with more than 30 million people voting – the highest turnout at a UK-wide vote since 1992.
Wales and the majority of England outside London voted in large numbers for Brexit.
UKIP leader Nigel Farage – who has campaigned for the past 20 years for Britain to leave the EU – told cheering supporters “this will be a victory for ordinary people, for decent people”.
Mr Farage – who predicted a Remain win at the start of the night after polls suggested that would happen – said it would “go down in history as our independence day”.
He called on Prime Minister David Cameron, who called the referendum but campaigned passionately for a Remain vote, to quit “immediately”.
But pro-Leave Conservatives including Boris Johnson and Michael Gove have signed a letter to Mr Cameron urging him to stay on whatever the result.
Gove and Johnson are considered leading contenders to replace Cameron in 10 Downing Street.
Labour leader Jeremy Corbyn, who called for the UK to remain in the EU but was accused of a lukewarm campaign, said poorer communities were “fed up” with cuts and felt “marginalised by successive governments”.
“Clearly there are some very difficult days ahead,” he said, adding that “there will be job consequences as a result of this decision”.
Cameron will have to decide when to trigger Article 50 of the Lisbon Treaty, which would give the UK two years to negotiate its withdrawal.
Once Article 50 has been triggered a country cannot rejoin without the consent of all member states.