THE script on any legal challenge to the competence of the Scottish Government’s Referendum Bill seemed well settled. At least until yesterday afternoon.

When the First Minister announced she’d give an update to Parliament before the summer recess on progress towards a second referendum, nobody expected a bill would be published and papers served on the UK Government to propel the case immediately into the Supreme Court.

It is worth sketching what we thought would happen with this bill – and why the FM’s announcement caught everyone off guard. The anticipated timeline went something like this. The Scottish Government would introduce a referendum bill, and say it believed it fell within Holyrood’s legislative competence. The opposition and UK Government would disagree.

Much of the scrutiny of the proposal would focus on contested issues of whether the bill fell within the Scottish Parliament’s powers. Lawyers would be called, other lawyers would disagree with them – and process, process, process would dominate the debate on independence.

READ MORE: Scottish independence: Boris Johnson responds as Nicola Sturgeon sets indyref2 date

Procedurally, there would be important staging posts along the way to the final vote. The minister introducing the bill would have to take a view on competence. The Presiding Officer would have her own say whether she thought the bill passed the test.

Pressure would be brought to bear to persuade the Scottish Government to publish its legal advice in full. And after all that, it seemed guaranteed Holyrood’s pro-independence majority would pass the bill.

We certainly anticipated this would only be the end of the beginning. Section 33 of the Scotland Act gives the UK law officers – as well as the Lord Advocate – the power to refer a bill to the Supreme Court for scrutiny after it has been passed by MSPs but before it receives royal assent.

Essentially, this is an opportunity for the court to decide whether a bill’s provisions fall within – or outwith – Holyrood’s powers before they become law.

The idea the Scottish Government’s chief legal adviser would choose to refer the bill to the Supreme Court was discounted – probably prematurely – but there seemed every likelihood the Attorney General for England and Wales and the Advocate General for Scotland would put their heads together to challenge the proposal.

If the UK Government got cold feet about taking the blame for stymieing a second poll, then a well-resourced punter with deep pockets and a passion for the Union seemed guaranteed to emerge, challenging the legislation by way of a judicial review in the Outer House of the Court of Session, and all the layers of appeal thereafter.

After the First Minister’s statement yesterday, that timeline and those assumptions have been blown to smithereens – catching the opposition, the UK Government and the Scottish media entirely off guard. What we all missed was an unloved, unused – but powerful – provision in Schedule 6 of the Scotland Act.

This part of the act is concerned with what are called “devolution issues” and how courts resolve them. Broadly speaking, these are disputes about the legal powers of the Scottish Parliament and Government under the Scotland Act.

Devolution issues usually pop up in civil or criminal cases. But paragraph 34 of Schedule 6 adds another way for disputes over “devolution issues” to reach the courts.

It is a simple power. It says that the Lord Advocate “may refer to the Supreme Court any devolution issue which is not the subject of proceedings” for adjudication. In essence, this means any devolution issue which hasn’t cropped up in the context of a civil and criminal case can nevertheless be referred to the Supreme Court for resolution. And this is precisely what Dorothy Bain QC has agreed to do with the indyref2 proposals.

The National: National Extra Scottish politics newsletter banner

As the Supreme Court confirmed yesterday afternoon, this “reference does not need permission for it proceed” – nor can the move be vetoed by the UK Government or its law officers, who now face the prospect of a full UK Supreme Court hearing sooner rather than later – with no opportunity to duck the issue or for a friendly pro-Union litigant to take the political hit on their behalf.

It remains to be seen whether they try to persuade the Court not to give the definitive ruling the Scottish Government is looking for, deciding once and for all whether a referendum falls within Holyrood’s powers.

There are technical arguments they might try to run to persuade the court to decline to make a substantive ruling, to determine this isn’t a “devolution matter” narrowly conceived. But ultimately, what for?

Devolution may be more than 20 years old, but the law underpinning it still retains the capacity to surprise. The lesson? Always read the small print. And seize your political opportunities as they come.