In the speech announcing his resignation, David Cameron included a list of the things he was proud to have done as prime minister. I suspect you glazed over at that point. So will future biographers of his premiership. He has just become one of those leaders who will be remembered for a single enormous mistake. Neville Chamberlain had achievements to his name before appeasement. There was more to Anthony Eden than the Suez debacle. Lord North had a career before he lost America. But each of those premiers is defined by their one towering disaster. So it will be with David Cameron, the prime minister who accidentally ruptured more than four decades of his country’s economic, security and foreign policy by losing the referendum on Europe. That will be the inscription etched deep on his tombstone.

He staked his reputation and gambled his country’s place in the world on a referendum for which his party ached but the public hardly clamoured. He timed the vote and chose a moment that has proved to be a calamity for the cause to which he became a belated, and thus not very convincing, champion. He destroyed his premiership because he misjudged the politics and mishandled his enemies. The man who arrived as leader of his party pledging to purge its obsession with “banging on about Europe” has blown himself up over Europe. And potentially much else besides. With Nicola Sturgeon seizing on the perfect rationale for another attempt to gain independence for Scotland, he may also be remembered as the man who unravelled the United Kingdom, achieving the double whammy of expelling his country from one union and breaking an even older one.

He had no choice but to quit. The Tory party, now in the process of a takeover by the Brexiters, would never have trusted him with the divorce negotiations. And how could he have looked his European peer group in the eye? Having solemnly assured them that he would keep Britain in, they could not have taken him seriously in the great effort that will be needed to manage the aftermath.

Watching him make his near tearful statement in Downing Street, you had to pinch yourself to remember that, just over a year ago, he had stood in the same spot celebrating an unexpected election victory, the best for any Tory leader in more than 20 years. He won last May by pitching himself as the guarantor of stability. Twelve months on, his legacy to his country is grave economic uncertainty and wild political febrility. He aspired to fashion One Nation. He leaves his country vividly split.

This referendum was an x-ray of the body politic of the nation and it revealed multiple fractures in this disunited kingdom. Two of its constituent parts voted one way, two the other. London and the majority of people in the big cities were on one side, rural and provincial England on the other. We are a country starkly divided between doing-well Britain and left-behind Britain, between the Britain that is essentially comfortable with globalisation and diversity and the Britain that feels its anxieties and anger about identity loss have not been listened to.

It was about class, but it was as much about generation. That is perhaps the most intense and alarming divide. Feel the anger of the young, overwhelmingly for In, as they are defeated by Out-voting pensioners. Oldsters who voted Out because they felt politics had let them down now have their mirror in young people who cast for In and feel their future has been stolen from them.

It further highlighted the chasm between parliament and people. All of the major party leaders bar Nigel Farage recommended a vote to remain. More than half the country told them where they could shove their advice. In the current mood of seething cynicism about anything that can be construed as “elite” or “establishment”, that is not such a surprise. Nor is it a great shock to find so many voters disinclined to listen to the advice of bankers and economists. The Inners were over-convinced that fear about the economic consequences of Brexit was their trump card. All their warnings of imminent apocalypse could not speak persuasively to the many millions of Britons who felt that it wasn’t a risk for them because they had nothing to lose. The rejection of “elite opinion” went deeper still. Remain was also supported by many bodies of opinion that commonly score well with the public in trust ratings, such as doctors. They were also told to get stuffed.

Well, by just over half the country. The most important choice made by the UK since 1945 was by a narrow margin; 17 million voted one way; 16 million the other. Had 634,751 people put their cross in the other box, the outcome would have been reversed. For those on the losing side, that feeds the recriminatory feeling that it could have been otherwise if only things had been done a bit differently. That is helping to fuel the insurrection by Labour MPs against Jeremy Corbyn.

Some of those divisions were germinating long before Mr Cameron arrived at Number 10. His destructive contribution was to give a polarising focus for their expression by staging this referendum and doing so at a very unpropitious point in the political cycle. His timing was atrocious. His renegotiation of membership was announced unilaterally. He set a deadline that was out of sync with the needs of the rest of Europe. He staged the vote at a point when the EU was not a good advertisement for itself. He was nearing his sell-by-date as a leader. To compound that, and this I suppose he could not have foreseen, the Labour party was in terrible shape to help him out.

The humiliation of a Tory prime minister would normally be a cause of celebration for Labour, but there is nothing here to cheer the party. Its failure to mobilise erstwhile Labour supporters for Remain made a crucial difference and is panicking its MPs about the fate that could befall them if a new Tory leader triggers an early election. That is the spur for Mr Corbyn’s internal opponents to make their attempt to unseat him. This puts us in the extraordinary position of the prime minister being compelled to announce his resignation while the leader of the opposition is simultaneously threatened from within his ranks. We would normally regard that as sensational. Yet in these strange days the fates of these two men seem relatively trivial compared with what Brexit will entail.

The next prime minister will most likely be Boris Johnson. If he doesn’t know it already, he will quickly discover that voting for departure was the easy bit. Whatever the identity of the next prime minister, he or she will have to bend to the geographical and economic facts of life: we can leave the EU, but we can’t quit Europe because it is our continent. What lies ahead is a protracted and tortuous renegotiation of our relationship with our closest neighbours and most important markets. With goodwill on both sides, it is conceivable that an amicable arrangement could emerge. The British used to have a talent for pragmatic compromise. The EU too. But goodwill is in very short supply at the moment.

It will be a formidable challenge for Britain’s next prime minister to make an economic, diplomatic and political success out of Brexit. Or, to set the bar at a more realistic level, to contain the damage. Nigel Farage, empowered by this result, will be breathing down the neck of the next occupant of Number 10 and itching to denounce anything less than total divorce as a betrayal. The talks with EU leaders will require seriousness, finesse, diplomacy and a capacity for building trusting relationships, not qualities usually associated with Mr Johnson. It will also require flexibility, which is more his forte.

Some of the leading Brexiters – Dan Hannan has been thoughtful about this – have tempered their triumphalism with an acknowledgement that they need to respect the wishes of the 48% who wanted a different result. They hint at a compromise, perhaps some sort of “associated member” status for Britain, which would preserve at least some access to the single market.

That is not a stupid avenue to explore. But it will be hard to sell to a shocked EU leadership, many of whom feel it is essential to demonstrate that departure is not a pain-free option. I hope I’m wrong to think that Britain has made a choice that will have very bad consequences, because I don’t wish disaster on my country. But among the things to fear is what happens when the millions of poorer Britons who were seduced by the Brexiters discover that it is not the miracle solution to their discontents that they were promised.

Many mighty imponderables now face Britain and the people who will soon take charge of our divided country. The leaders of Leave have won and by doing so they have shocked the world, unleashed profound economic instability, exploded our relations with our closest allies, toppled a prime minister elected just a year ago and imperilled the unity of the United Kingdom.

As the old saying goes: they broke it, now the Brexiters own it. Which may explain why, as mournful as David Cameron was in defeat, Boris Johnson and Michael Gove looked even grimmer in victory.