If all had gone to plan, Britain would be starting its first summer out of the European Union and Prime Minister Theresa May would be looking forward to a well-earned vacation.

Instead, May steps down Friday as leader of a Conservative Party in turmoil and a country in limbo — half in, half out of the EU. She will remain as caretaker prime minister for a few weeks during a party leadership contest to choose her successor.

May will be remembered as the latest in a long line of Conservative leaders destroyed by the party's divisions over Europe, and as a prime minister who failed in her primary mission: to lead Britain out of the EU. But history may also see her as a leader who faced a devilishly difficult situation with stubborn determination.

The daughter of a rural Anglican vicar, May attended Oxford University and worked in financial services before being elected to Parliament in 1997.

She was quiet and diligent, but also ambitious. One university friend later recalled that May hoped to be Britain's first female prime minister, and "was quite irritated when Margaret Thatcher got there first."

She was not a natural political campaigner; her stiff public appearances as prime minister landed her the nickname "The Maybot." Her only touches of flamboyance are a fondness for bold outfits and accessories like brightly patterned kitten-heel shoes.

But she soon established a reputation for solid competence and a knack for vanquishing flashier rivals.

May served for six years in the notoriously thankless job of home secretary, responsible for borders, immigration and law and order. In 2016, she beat flashier and better-known politicians to become Britain's second female prime minister.

May was the surprise winner of a Conservative leadership contest triggered when Prime Minister David Cameron stepped down after voters rejected his advice to remain in the EU, instead voting 52%-48% to leave.

In her first speech as prime minister in July 2016, May sketched out plans for an ambitious policy agenda. She spoke of giving the poor a helping hand and lifting barriers to social mobility.

But Brexit soon crowded out almost all other policies.

Like Cameron, May had campaigned to remain, but in office she became a champion of Brexit. "Brexit means Brexit" became her mantra — a meaningless one, said her detractors, as it emerged that undoing 45 years of ties with the bloc would be a fraught and complex process.

Attempting to win the support of Conservative Brexiteers suspicious of her past pro-EU leanings, May set out firm red lines in negotiations with the EU: Britain would leave the bloc's single market and customs union and end the right of EU citizens to live and work in the U.K.

For a time, May's resolve helped her unite the warring factions of her party, which for decades has been divided over policy toward Europe.

But she then gambled on a snap election in June 2017, in an attempt to bolster her slim majority in Parliament and strengthen her hand in Brexit negotiations with the EU.

The move backfired. May ran a lackluster campaign on a platform that included plans to cut benefits to pensioners and change the way they pay for long-term care — quickly dubbed a "dementia tax." The Conservatives lost their majority, and May had to strike a deal with 10 lawmakers from Northern Ireland's Democratic Unionist Party to stay in power.

The DUP's support became a complication when the border between Northern Ireland and EU member Ireland emerged as a major issue in Brexit negotiations. The unionist party strongly opposed special measures to ensure the border remained free of customs posts and other barriers, worrying they might weaken the bonds between Northern Ireland and the rest of the U.K.

May pressed on and in November 2018 struck a divorce agreement with the EU, setting out the terms of Britain's departure and establishing a transition period of almost two years for the two sides to work out their future relations.

All that remained was for the British and European Parliaments to ratify it. And that is where May's best-laid plans came undone.

Her careful compromise of an agreement was rejected by both sides of the Brexit debate. Brexiteers felt it gave too much away and left Britain bound to EU rules. Pro-EU lawmakers wanted a softer Brexit that kept close economic ties to the bloc. In January, May's deal was rejected by 230 votes, the biggest government defeat in British parliamentary history.

Whatever her flaws, May was no quitter. Late last year she likened herself to Geoffrey Boycott, a cricketer who was famous for his dull but effective batting style.

"Geoffrey Boycott stuck to it and he got the runs in the end," she said.

She tried again to get her Brexit deal approved, losing by 149 votes. A third attempt narrowed the margin of defeat to 48.

She tried talks with the Labour Party about securing a compromise, but managed only to further alienate her own lawmakers with her concessions to the opposition. A promise to let Parliament vote on whether to hold a new EU membership referendum was the final straw.

Most Conservatives, even those sympathetic to her plight, concluded that May was the problem and would have to leave before Brexit could be sorted out.

Now almost a dozen Conservative lawmakers are competing to succeed her as Conservative leader and prime minister. Party members and lawmakers are scheduled to choose the winner by the end of July.

The leading candidates, including Brexit champion Boris Johnson, Environment Secretary Michael Gove and Foreign Secretary Jeremy Hunt, all vow to succeed where she has failed and lead Britain into the sunlit uplands outside the EU.

Only May, perhaps, knows how hard that will be.

"To succeed he or she will have to find consensus in Parliament where I have not," May said in her May 24 resignation statement. "Such a consensus can only be reached if those on all sides of the debate are willing to compromise."

___

Follow AP's full coverage of Brexit at: https://www.apnews.com/Brexit