In an emotional statement, she said she had done her best to deliver Brexit and it was a matter of “deep regret” that she had been unable to do so. Mrs Theresa May said she would continue to serve as PM while a Conservative leadership contest takes place.
The party said it hoped a new leader could be in place by the end of July.
It means Mrs May will still be prime minister when US President Donald Trump makes his state visit to the UK at the start of June.
Asked about the prime minister’s announcement, Mr Trump said: “I feel badly for Theresa. I like her very much. She’s a good woman. She worked very hard. She’s very strong.”
Mrs May said she would step down as Tory leader on 7 June and had agreed with the chairman of Tory backbenchers that the contest to replace her should begin the following week.
Foreign Secretary Jeremy Hunt has become the latest MP to say that he will run, joining Boris Johnson, Esther McVey and Rory Stewart. More than a dozen other MPs are believed to be seriously considering entering the contest.
In the end, May was overwhelmed
At the start she boasted about not being a creature of Westminster’s bars and cliques.
But it meant this very private politician had few true friends to help when things turned sour, and neither the powers of patronage, nor the capability to schmooze or arm twist to get people around to her point of view.
Few of her cabinet colleagues, even now, know her well at all, one saying that “as things got harder the circle got smaller”. Another revealed that “there was no trust, and no faith”.
Settling the Tories’ decades-long dispute over Europe was always perhaps beyond just one leader. But the wounds have got more painful under her leadership, rather than fading away.
In her statement, delivered in Downing Street, Mrs May said she had done “everything I can” to convince MPs to support the withdrawal deal she had negotiated with the European Union but it was now in the “best interests of the country for a new prime minister to lead that effort”.
She added that, in order to deliver Brexit, her successor would have to build agreement in Parliament.
“Such a consensus can only be reached if those on all sides of the debate are willing to compromise,” she said.
Mrs May’s voice shook as she ended her speech saying: “I will shortly leave the job that it has been the honour of my life to hold. The second female prime minister, but certainly not the last.
“I do so with no ill will, but with enormous and enduring gratitude to have had the opportunity to serve the country I love.”
The prime minister had faced a backlash from her MPs after announcing her latest Brexit plan earlier this week, which included concessions aimed at attracting cross-party support.
The Conservative Party said the likely timetable for the leadership contest was that nominations would close during the week beginning 10 June, with candidates whittled down to the final two to by the end of the month.
Those names would then be put to a vote of party members before the end of July.
Former foreign secretary Boris Johnson, who is seen as the front-runner to succeed Mrs May, told an economic conference in Switzerland on Friday: “We will leave the EU on October 31, deal or no deal.”
He said a new leader would have “the opportunity to do things differently”.
Labour Leader Jeremy Corbyn said Mrs May had been “right to resign” and that the Conservative Party was now “disintegrating”.
Theresa May is right to resign. She’s now accepted what the country’s known for months: she can’t govern, and nor can her divided and disintegrating party.
Whoever becomes the new Tory leader must let the people decide our country’s future, through an immediate General Election.
Foreign Secretary Jeremy Hunt called her a “true public servant” and Chancellor Philip Hammond said it had been a “privilege” to serve alongside her.
Mrs May’s predecessor, David Cameron – who resigned as prime minister after campaigning for Remain and losing the referendum – said she should be thanked for her “tireless efforts”.
He added: “I know how painful it is to accept that your time is up and a new leader is required. She has made the right decision and I hope that the spirit of compromise is continued.”
Scotland’s First Minister Nicola Sturgeon wished Mrs May well despite “profound disagreements” but added: “The prospect of an even more hard-line Brexiteer now becoming PM and threatening a no-deal exit is deeply concerning.”
Democratic Unionist Party Leader Arlene Foster, whose party supported Mrs May’s government in power after the Conservatives lost their majority in the 2017 election, praised Mrs May’s “dutiful approach on national issues”.
Lib Dem leader Sir Vince Cable said Mrs May’s compromises with the right-wing of her party had been blame for her departure, adding: “The best and only option remains to take Brexit back to the people. I believe the public would now choose to stop Brexit.”
But Brexit Party Leader Nigel Farage said two Conservative leaders whose “instincts were pro-EU” had now gone and the party either “learns that lesson, or it dies”. – AP