All good dramas involve the suspension of disbelief. So it was with Brexit. I went to bed at 4am on Friday depressed that Britain had voted to leave the EU. The following day my gloom only deepened. But then, belatedly, I realised that I have seen this film before. I know how it ends. And it does not end with the UK leaving Europe.

Any long-term observer of the EU should be familiar with the shock referendum result. In 1992 the Danes voted to reject the Maastricht treaty. The Irish voted to reject both the Nice treaty in 2001 and the Lisbon treaty in 2008.

And what happened in each case? The EU rolled ever onwards. The Danes and the Irish were granted some concessions by their EU partners. They staged a second referendum. And the second time around they voted to accept the treaty. So why, knowing this history, should anyone believe that Britain’s referendum decision is definitive?

It is true that the British case has some novel elements. The UK has voted to leave the EU altogether. It is also a bigger economy than Ireland or Denmark, which changes the psychology of the relationship. And it is certainly true that the main actors in the drama seem to think it is for real. David Cameron, the UK prime minister, announced his resignation following the vote; and Jonathan Hill, Britain’s EU commissioner for financial services, has followed suit.

Yet there are already signs that Britain might be heading towards a second referendum rather than the door marked exit. Boris Johnson, a leader of the Leave campaign and Britain’s probable next prime minister, hinted at his real thinking back in February, when he said: “There is only one way to get the change we need — and that is to vote to go; because all EU history shows that they only really listen to a population when it says No.”

Having been a journalist in Brussels at the time of the Danish referendum on Maastricht, Mr Johnson is very familiar with the history of second referendums. It is also well known that he was never a diehard Leaver, and hesitated until the last moment before deciding which side to back.

His main goal was almost certainly to become prime minister; campaigning to leave the EU was merely the means to that end. Once Mr Johnson has entered 10 Downing Street, he can reverse his position on the EU.

But would our European partners really be willing to play along? Quite possibly. You could see that in the talk by Wolfgang Schäuble’s finance ministry in Germany of negotiating an “associate” membership status for Britain. In reality, the UK already enjoys a form of associate membership since it is not a participant in the EU’s single currency or the Schengen passport-free zone. Negotiating some further ways in which the country could distance itself from the hard core of the bloc, while keeping its access to the single market, would merely elaborate on a model that already exists.

And what kind of new concession should be offered? That is easy. What Mr Johnson would need to win a second referendum is an emergency brake on free movement of people, allowing the UK to limit the number of EU nationals moving to Britain if it has surged beyond a certain level.

In retrospect, it was a big mistake on the part of the EU not to give Mr Cameron exactly this concession in his renegotiation of the UK’s terms of membership early this year. It was the prime minister’s inability to promise that Britain could set an upper limit on immigration that probably ultimately lost him the vote.

Even so, with 48 per cent of voters opting to stay in the union, the result was extremely close. If the Remain campaign could fight a second referendum with a proper answer to the question of immigration it should be able to win fairly easily.

But why should Europe grant Britain any such a concession on free movement? Because, despite all the current irritations, the British are valuable members of the EU. The UK is a big contributor to the budget and it is a serious military and diplomatic power.

Just as it will be painful for the UK to lose access to the EU’s internal market, so it will be painful for the EU to lose access to the British labour market. More than 3m EU nationals live and work in Britain, with more than 800,000 from Poland alone.

Agreeing to an emergency brake on free movement of people might mean some modest limits to future migration. But that would surely be better than the much harsher restrictions that could follow a complete British withdrawal from the EU.

Of course, there would be howls of anger on both sides of the Channel if any such deal is struck. The diehard Leavers in Britain would cry betrayal, while the diehard federalists in the European Parliament — who want to punish the UK and press on with “political union” in Europe — will also resist any new offer.

But there is no reason to let the extremists on both sides of the debate dictate how this story has to end. There is a moderate middle in both Britain and Europe that should be capable of finding a deal that keeps the UK inside the EU.

Like all good dramas, the Brexit story has been shocking, dramatic and upsetting. But its ending is not yet written.

gideon.rachman@ft.com

Letters in response to this column:

Forecasters of doom and gloom are often wrong / From Han de Jong

You’ve been a hindrance. Now leave quietly / From Luca Romano

Let UK leave as a lesson on pseudo-democracy / From Dr Liubomir K Topaloff

Why should the British not reject feckless policies? / From Janet Tavakoli