Theresa May fought back tears as she announced she will resign on 7 June, following months of pressure.
Mrs May said she had “done my best” to get her Withdrawal Agreement through parliament and to give people what they had voted for in the Brexit referendum of 2016.
“I believe it was right to persevere even when the odds against success seemed high,” she said.
But she acknowledged her failure, saying: “It is and will always remain a matter of deep regret to me that I have not been able to deliver Brexit.”
Watched by husband Philip and her closest aides, she said: “It is now clear to me that it is in the best interests of the country for a new prime minister to lead that effort.
“So I am today announcing that I will resign as leader of the Conservative and Unionist Party on Friday 7 June.”
Fighting back tears, she said she was leaving the job “with no ill will”, adding that she was “the second female prime minister but certainly not the last”.
Concluding her statement, Mrs May broke down as she said it had been “the honour of my life” to serve “the country that I love”.
The prime minister’s resignation now starts a contest to become Britain’s next prime minister.
She will remain as a caretaker prime minister until the new leader is chosen and this could take several weeks.
Mrs May’s announcement comes after a showdown this morning with Sir Graham Brady, chair of the 1922 committee of Tory MPs.
It also marks the end of a difficult week, after more MPs demanded her immediate resignation and a senior cabinet minister quit.
Brexiteer Andrea Leadsom said she could not support the revamped Withdrawal Agreement Bill because it did not respect the referendum result.
But on Friday Mrs Leadsom said Mrs May’s speech was “an illustration of her total commitment to country and duty”.
One of the candidates to replace Mrs May, Dominic Raab, described her as “dignified as ever…she remains a dedicated public servant”.
Mrs May’s chief of staff Gavin Barwell said: “I have seen at first hand her commitment to public service and her incredible resilience as she has confronted the biggest challenge any British government has faced since the Second World War. It has been an honour to serve her.”
Meanwhile, the UK is currently due to leave the European Union on 31 October, but parliament has yet to approve the terms.