With Boris Johnson seemingly determined to take Britain out of the European Union on October 31 come hell or high water, MPs from all parties are debating how they can stop a no-deal Brexit. One of the options under consideration is a motion of no-confidence, but Downing Street adviser Dominic Cummings has suggested that Johnson might simply ignore such a vote and opt for a General Election after Brexit day instead. This has led to speculation that the Queen might enter the political fray and dismiss Johnson. But what circumstances might compel Her Majesty to act?
As a matter of law, the Sovereign can dismiss the Prime Minister at any time and for any reason, but no monarch has dismissed a Prime Minister since William IV sacked Viscount Melbourne in 1834. Under modern constitutional conventions, the Sovereign could only realistically dismiss a Prime Minister if they refused to resign after losing the confidence of the House of Commons.
However, the Fixed-term Parliaments Act 2011 complicates matters. Under section 2 of the Act, a successful motion of no-confidence kicks off a 14-day period in which the House of Commons must resolve that it has confidence in a government or else there must be an early General Election. Unfortunately, it’s not clear how this provision would work in practice as it’s never been tested before. Since the Sovereign must always have responsible advisers, Johnson would presumably stay in Downing Street until a viable alternative Prime Minister emerged. Consequently, the Queen would only need to dismiss Johnson if he refused to step down after losing a confidence vote and there was a clear successor waiting in the wings.
The political arithmetic in the Commons adds another layer of complexity. Ordinarily, the Leader of the Opposition would be the prime candidate to lead an alternative administration, but Jeremy Corbyn would likely need at least some support from the Conservative benches in order to have a stab at forming a government. Even though a number of Tory MPs have said they would be willing to bring down a Johnson government in order to stop a no-deal Brexit, they might be reluctant to give Corbyn the keys to Downing Street.
There’s been chatter about the possibility of a government of national unity led by someone other than Corbyn (e.g., a prominent backbencher such as the Tory Kenneth Clarke or Labour’s Yvette Cooper), but Labour’s hostility to the idea would make it difficult to pull off such a maneuver. It could also be a challenge to convince the Queen that such a government could actually command the confidence of the Commons since this arrangement would likely cut across party lines in all sorts of strange ways. And while opposition to a no-deal Brexit is strong, MPs would need to agree on an alternative plan of action. Would a government of national unity seek to revoke Article 50 and stay in the EU, or would they request an extension of the Article 50 in order to hold a General Election or a second referendum? Given the Commons’ fissiparousness thus far, it’s far from certain that any of the alternatives to a no-deal Brexit could win enough support from MPs to sustain a government of national unity.
If MPs can’t remove Johnson from Downing Street by the end of the 14-day period, then he would control the timing of the ensuing General Election, and he would be free to schedule the poll after Brexit day. One could argue that this would be unconstitutional, but it wouldn’t be unlawful, so the chances of the Queen intervening would seem slim.
The bottom line is that MPs are going to have to proceed very
carefully if they want to get rid of Johnson and stop a no-deal Brexit.
 William commissioned Sir Robert Peel, but he was defeated in the ensuing General Election, whereupon the King had no choice but to ask Lord Melbourne to form an administration. While no British monarch has dismissed a government since then, the Crown’s representatives in the Commonwealth realms have sacked premiers on several occasions over the years. The most famous example of this is probably Sir John Kerr’s decision to sack Gough Whitlam in 1975.
 There may well be other situations where the Crown could dismiss a Prime Minister (e.g., a Prime Minister acting illegally), but they’re beyond the scope of this post. For a comprehensive discussion of the subject, see Anne Twomey, The Veiled Sceptre: Reserve Powers of Heads of State in Westminster Systems (Cambridge: Cambridge University Press, 2018), 232-353.
 The new Prime Minister would then have to win a vote of confidence in order to forestall a General Election.
 While Tories opposed to no-deal might be willing to support a government of national unity, some pro-Brexit Labour MPs might vote against it because they feel that is the best way to respect the result of the referendum.
 Section 2(7) of the Fixed-term Parliaments Act 2011 states that, when there is an early General Election, the polling day is set by the Queen on the recommendation of the Prime Minister.