When David Cameron was elected leader of Britain's Conservative Party, the press called him the "heir to Blair." Like Labour premier Tony Blair, he was a young leader who dragged his sometimes reluctant party toward the political center.

Cameron steps down Wednesday after six years as prime minister — like Blair, defined by a historic blunder.

For Blair, it was the 2003 invasion of Iraq. For Cameron, it was the decision to call a referendum on Britain's European Union membership. He gambled that voters would choose to remain, after a cathartic debate that would resolve Conservative Party divisions on Europe.

Instead, Britain voted by 52 percent to 48 percent to leave — and a tearful Cameron announced his resignation the next morning, saying "I do not think it would be right for me to try to be the captain that steers our country to its next destination."

He was due to stay on until the party picked a new leader in September, but on Monday Home Secretary Theresa May was chosen as Conservative chief after her main opponent dropped out. British politics can be brutal — the moving vans were pulling up to 10 Downing St. the next day.

Cameron's six-year term as prime minister will be remembered for its sudden, self-inflicted end. But historian Anthony Seldon said there were substantial achievements, too.

"Yes, it ended in disaster," Seldon told BBC radio.

But he said Cameron was "a substantial historical figure who also emerged victorious from two general elections, reshaped his party, instituted a whole range of left-of-center, progressive Conservative reforms including gay marriage, pressed for money to go to development and modernized the party."

When he took office in 2010, the 43-year-old Cameron was Britain's youngest prime minister in almost 200 years. He failed to win an outright majority in Parliament, so formed a coalition with the smaller Liberal Democrats. It was a compromise that suited him. The government was fiscally conservative and socially reforming, much like Cameron himself.

The confident, easygoing product of a privileged background — the first prime minister to say he liked to "chillax" — Cameron said he hoped to be remembered as a social reformer. He encouraged a vision of a "Big Society" built on volunteering and community activism and cited legalizing same-sex marriage as one of his proudest achievements — although it cost him the support of some socially conservative Tories.

His government had to deal with a stagnating economy after the 2008 global financial crisis, and brought in deep public-spending cuts in a bid to reduce the country's ballooning deficit. Cameron managed to deflect much of the blame onto the previous Labour government, accusing it of fiscal recklessness.

Internationally, Cameron was wary of the interventionism that had led Blair to take Britain into the 2003 U.S.-led invasion of Iraq. When he sought Parliament's approval to join a campaign of air strikes against the Assad regime in Syria in 2013, lawmakers defeated him.

However, Britain did join a campaign of strikes against Islamic State group targets in Iraq the next year and expanded them to Syria in 2015.

But it was Britain's relationship with European Union neighbors and allies that proved his undoing, just when everything seemed to be going his way.

Cameron was re-elected in 2015 with an unexpected Conservative majority after campaigning on his economic record and vision of a "modern, compassionate Conservative Party."

But the final year of his premiership was overshadowed by what he had once called the party's predilection for "banging on about Europe."

Under pressure from the right-wing U.K. Independence Party and euroskeptics in his own party, Cameron called a referendum on membership of the 28-nation bloc.

He had already won two referendums, easily defeating a bid to introduce voting reforms in 2011 and by a narrower margin keeping Scotland in the United Kingdom in 2014.

But the third proved a vote too far. Cameron will be remembered as the prime minister who took Britain out of the EU and — potentially — triggered the breakup of the United Kingdom. Scotland voted strongly to remain in the EU, and the vote has given new momentum to demands for a second independence referendum.

Jon Davis of the Policy Institute at King's College London said that in many ways Cameron was a successful leader.

"He was a steady prime minister, he was competent, he was good-hearted," Davis said. "If it had been 52-48 the other way, we would be talking about a great leader, a great prime minister."

Instead, "what we have is an abject failure that he has to live with for the rest of his life."

___

Follow Jill Lawless on Twitter at http://Twitter.com/JillLawless