LONDON -- Theresa May became prime minister in 2016 with one overriding goal: to lead Britain out of the European Union.
Three years on, the U.K. is still in the EU, and May's time in 10 Downing St. is ending. She announced Friday that she will step down as Conservative leader on June 7, remaining as caretaker prime minister during a party leadership contest to choose her successor.
She 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. 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, including Brexit-backer Boris Johnson -- now the favourite to succeed her -- to become Britain's second female prime minister, after Margaret Thatcher.
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 lacklustre 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.
By this time, a growing number of Conservatives had concluded that May was the problem and would have to leave before Brexit could be sorted out.
But she resisted the pressure, planning instead to try for a fourth time by bringing a withdrawal agreement bill to Parliament for a vote.
In the end, the pressure became irresistible.
"I think the most sympathetic reading of her premiership is that she was delivered a very poor hand by her predecessor, and she dealt with it very badly," said Steven Fielding, professor of political history at the University of Nottingham.
"It was unfortunate circumstances she found herself in, but she made them worse."