One thing has been made clear in this EU referendum campaign – the political gods have a sense of humour.

A Prime Minister who famously told his party to stop “banging on about Europe” now faces a mortal threat to his career as a direct consequence of the most cacophonous ‘banging-on-about-Europe-fest’ this country has ever seen.

David Cameron’s fate depends on many factors. Obviously, if Britain votes to leave the EU his position will be considerably more precarious – but it is not a clear cut question of ‘Leave, he goes’ and ‘Remain, he stays’.

Dave Brown on David Cameron Show all 11 1 /11 Dave Brown on David Cameron Dave Brown on David Cameron 4 March 2016 Boris Johnson campaigns for Brexit Dave Brown on David Cameron 20 January 2016 Cameron's response to Tata Steel job cuts Dave Brown on David Cameron 5 January 2016 Cameron's reaction to Saudi Arabia executions Dave Brown on David Cameron 3 December 2015 Cameron called the opponents of military action in Syria "terrorist sympathisers" Dave Brown on David Cameron 2 December 2015 Cameron and the Syria bombing vote Dave Brown on David Cameron 19 November 2015 Cameron moves toward a second vote on bombing Syria Dave Brown on David Cameron 21 October 2015 Xi Jinping is lauded at a state banquet as British steelworkers lose their jobs, largely as a result of cheap Chinese steel imports Dave Brown on David Cameron 8 October 2015 Tory conference responds to Cameron’s keynote speech Dave Brown on David Cameron 6 October 2014 Clegg attempts to distance himself from Cameron Dave Brown on David Cameron 27 June 2014 Cameron and EU re-negotiation Dave Brown on David Cameron 1 December 2012 Cameron, Murdoch and the Leveson Report

To understand what might happen to Cameron after June 23rd, we must first go back to March 2015, when he made the surprise announcement that he would not stand for a third term as Prime Minister.

So we have known for a long time that a Conservative leadership election is coming sometime before the next General Election in 2020.

The outcome of the referendum will decide how soon that is. It could still be some years away. Equally, we might just have a new Prime Minister by Christmas.

What happens if we vote to leave?

If Britain votes to leave the EU, many think David Cameron will be forced to resign almost immediately. It may not be as simple as that.

Certainly, it would be an astonishing blow to his authority. The electorate would have completely rejected his stance on the biggest political question we have faced in decades. There is no doubt he would have to go – but how soon?

Some of the key Conservative figures in the Leave campaign – Boris Johnson, Michael Gove, Chris Grayling and Iain Duncan Smith – have said they want to see Cameron stay on even if we vote to leave. Cameron himself has pledged to see out the job, to carry out the will of the British people.

Some of his Eurosceptic backbenchers have been less charitable, and there are reports that anywhere between 50 and 100 would support a vote of no confidence – even if we narrowly vote to Remain.

David Cameron asked if he is 'finished as PM' after EU referendum

It only takes 50 Conservative MPs to trigger a vote of no confidence, which, if we leave, Cameron would struggle to win. So in the event of Brexit, it becomes a question of whether he jumps, or whether he is pushed.

However, in that situation, it seems likely that even Johnson, Gove et al would recognise that the Prime Minister (and probably the Chancellor) being forced to immediately resign would only increase global stock market uncertainty, posing a big risk to the UK economy.

So it may be that they are willing to keep their Eurosceptic troops at bay, and let Cameron stay on – but for only so long. The Prime Minister will be under pressure to name a date for his departure. It may be that he will offer to lead the initial stages of Britain’s complex withdrawal from the EU, pledging to stand down by, say, the end of 2017, once the broad terms of our new non-EU status have been thrashed out.

However, not even that may be enough for a parliamentary party and membership who want him out. Their fury is based not only on Cameron’s decision to back Remain, but a perception that Downing Street has patronised voters with scare story after scare story, and dishonourably used the machine of government to further their cause. In the eyes of those poor Eurosceptic backbenchers, it’s not just what he said, it’s the way he said.

So don’t rule out a vote of no confidence very soon after a Leave vote, regardless of the risk to political and economic security.

And no, we can’t even rule out the possibility that Cameron simply decide to resign immediately, if we vote to leave. The shock of it, and the grim prospect of carrying on in such circumstances, might be enough to make him forget all those previous assurances about staying on.

What happens if we vote to Remain?

This depends on how firmly Remain win. If we back staying in by 57 to 43 or by a bigger margin, Cameron looks safe for now. Even the most indignant Euroscpetic backbencher would find it hard to back a vote of no confidence in a leader whose stance had firmly secured the backing of the British people.

However, a big win for Remain looks increasingly unlikely. A narrow victory could still see Cameron facing a no confidence vote, forced by 50 or more hardliners. However, under these circumstances, he’d have a very good chance of winning it.

The problem arises further down the line. The Government has a majority of just 12. It wouldn’t take many Eurosceptic MPs, angry at the way he conducted the campaign, to turn him into a lame duck Prime Minister. With Boris Johnson pacing up and down outside the gates of Downing Street (so to speak), pressure to announce a departure date will be great.

Already committed to leaving before 2020, setting a departure date in 2018 would allow him to step down with some degree of dignity, while satisfying the clamour within the party for change. It would then become a battle between continuity candidate George Osborne and Eurosceptic darling Boris Johnson, with Theresa May and perhaps one or two others waiting to pip the frontrunners to the top job. In a Conservative leadership contest, MPs elect a shortlist of two, with the final decision in the hands of Conservative party members.

Will there be a General Election when Cameron stands down?

There is no rule that says there must be. However it’s possible that the eventual winner of a potential Conservative leadership election may want to call one. If Labour are not performing strongly in the polls by the time a new Tory leader is in place, then the new Prime Minister – whoever that might be – may feel inclined to cement their authority with a snap election. Under the Fixed Term Parliament Act introduced by the Coalition, this would require a two thirds majority in the House of Commons, so would need some Labour and SNP support.

Much would depend on the opposition parties’ stomach for a fight and, in Labour’s case, the unity between leadership and MPs.

Under these circumstances, it isn’t beyond the realms of possibility that there could be a General Election as soon as this year, but such an eventuality is probably more likely further down the line. Given the amount of political upheaval we’ve already seen recently, a potential new Tory leader is more likely to want to spend a year or two ‘bedding in’.