LONDON (Reuters) - British Prime Minister Boris Johnson is set for a battle of wills with parliament over Brexit that will test the country’s unwritten constitution.

European Union and British flags flutter in front of the chancellery ahead of a visit of British Prime Minister Theresa May in Berlin, Germany, April 9, 2019. REUTERS/Hannibal Hanschke

If the European Union refuses to renegotiate the terms of Britain’s departure, Johnson says he will take the country out without a divorce deal on Oct. 31. Some in parliament are determined to stop him.

Below are some of the likely moves and countermoves.

EARLY ELECTION

Parliament, where there is a small majority against a no-deal Brexit, can collapse Johnson’s government by holding a no-confidence vote.

An early election could elect a new government with a strategy to either delay Brexit or revoke the decision to leave the EU. But it is within Johnson’s power to delay any election until after Oct. 31, the date on which British law states the country will leave the EU, whether or not an exit deal has been agreed.

ALTERNATIVE GOVERNMENT

If the government loses a confidence vote there is a 14-day period in which a new administration can be formed.

If the majority who voted against Johnson formed an alternative government they could try to extend Britain’s EU membership beyond Oct. 31.

The electoral legislation allowing for this was introduced in 2011 and has never been tested in this way. It has been criticized for not defining exactly how the 14-day period would work and who has the power to do what during it.

Johnson could argue that he is not obliged to resign and decide to hold out until an election is triggered and then hold that election after Oct. 31.

COULD JOHNSON REFUSE TO RESIGN?

The document laying out the laws and conventions of government says that during the 14-day period: “The Prime Minister is expected to resign where it is clear that he or she does not have the confidence of the House of Commons and that an alternative government does have the confidence.”

But Stephen Laws, First Parliamentary Counsel from 2006-2012 (head of the government body responsible for drafting legislation), says like most things in Britain’s unwritten constitution, the rules are open to interpretation, subject to political forces and hard to enforce through the courts.

Although Queen Elizabeth appoints the prime minister and could technically dismiss him, that would tear up the convention that the monarch does not get involved in politics.

Johnson could argue that an alternative administration formed with the sole purpose of preventing a no-deal Brexit is not a true government.

Experts expect a legal challenge if he refuses to resign.

Others argue that it is parliament that would have to act.

“The bottom line is that if PM Johnson fails to resign after a no-confidence vote when an alternative is clear, a ‘constitutional crisis’ will ensue,” JPMorgan said in a note.

“In our view, it is unlikely that Johnson’s position would hold. But (Members of Parliament) have to act with force and make clear who that alternative is.”

CHANGE THE LAW

If Johnson does not step aside, lawmakers still have options. The rules of parliament have proven flexible and speaker John Bercow has broken precedents to allow opponents of Brexit to have their say.

Lawmakers would need to seize control of the parliamentary agenda and change the law, a repeat of an approach that proved successful earlier this year.

“A no-deal Brexit can be prevented only by legislation, not by a mere expression of parliamentary opinion,” constitutional expert Vernon Bogdanor of King’s College London, wrote in the Guardian newspaper.

The law changes could include requiring Johnson to seek an extension from Brussels, to explicitly rule out ever leaving without a deal, or to hold another referendum.

But the timetable to carry out such a plan is tight - parliament only sits for a limited number of days before Oct. 31 and the government can use its control of proceedings to limit any opportunity for opponents to make a move.