Media playback is unsupported on your device Media caption What happened at the Supreme Court and what could happen next?

This was no ordinary court case. The battle in the Supreme Court over the shutdown of Parliament is a historic test of the powers of the prime minister, MPs and the courts.

And it captured audiences: on the first day, the video stream was accessed 4.4 million times.

But if you didn't follow every twist and turn in three days of legal argument, here's a guide to what happened and why it matters.

The judgement is expected in the week beginning 23 September.

Why is the case so important?

For some in the crowds of people protesting outside, the outcome of Brexit seems to hang in the balance.

But the court was keen to emphasise that the case is not actually about Brexit. Lady Hale, president of the Supreme Court, said it is "solely concerned" with whether it was lawful for Boris Johnson to suspend Parliament through a process called prorogation.

That set the stage for a battle over the whole UK constitution and the limits of the prime minister's powers. Does he decide, through his advice to the Queen, when Parliament sits and when it doesn't? Can he be prevented from suspending it in some circumstances?

Image copyright Getty Images Image caption Demonstrators - against the shutdown and in favour of Brexit alike - made themselves heard outside court

BBC legal correspondent Clive Coleman said it is "a stress-test for our unwritten constitution".

Because there is no one place where all the rules of government are written down, the Supreme Court - which was only formally established 10 years ago - has to decide between the competing legal arguments.

Why did the Supreme Court case happen?

Two of the highest courts, one in England and one in Scotland, had previously considered the decision to suspend Parliament for five weeks - only to come to opposite conclusions.

In Scotland, the Inner House of the Court of Session ruled the government acted unlawfully because it had the "improper purpose of stymieing Parliament" in the crucial period before the 31 October Brexit deadline.

But in England's High Court, which uses a different legal system to Scotland, judges said it was lawful because it was a political matter, not a decision for the courts.

Image copyright Reuters Image caption Campaigner Gina Miller was seeking a second Supreme Court victory over the government

Image copyright Getty Images Image caption The SNP's Joanna Cherry led the case in the Scottish court

That meant all the parties had to bring their arguments to the Supreme Court, so it could break the deadlock.

The English case was brought by Gina Miller, the campaigner who previously forced the government to give MPs a vote on triggering the Brexit process. She was backed up by former prime minister Sir John Major.

A group of more than 70 Parliamentarians led by the SNP's Joanna Cherry QC brought the Scottish case.

Lawyers for the government were appealing against the decision in Scotland and defending the judgement in England.

What did the campaigners against suspending Parliament say?

The lawyers opposing the suspension sought to prove that Mr Johnson was trying to "silence Parliament" for five weeks - the longest period for 40 years - at a crucial political moment.

Lord Pannick QC, acting for Gina Miller, said: "The exceptional length of the prorogation in this case is strong evidence that the prime minister's motive was to silence Parliament for that period because he sees Parliament as an obstacle to the furtherance of his political aims."

He said the government is "junior partner" to Parliament and cannot claim "unfettered power" to close it down.

Sir John's lawyer, Lord Garnier QC, argued the documents submitted by the government to court did not provide "the true reason" for the suspension.

He said the "inescapable" conclusion was Mr Johnson was "motivated by his political interest" in shutting down Parliament before the EU summit on 17 and 18 October.

Image copyright EPA Image caption Lord Pannick QC, acting for Gina Miller, said the prime minister saw Parliament as an obstacle to his political aims

Aidan O'Neill QC, representing the Scottish Parliamentarians, stood out for his colourful turns of phrase. He summed up the case as the "mother of parliaments closed down by the father of lies", referred to "dirty tricks", and said the judges should not treat government documents as "gospel".

That upset the government lawyers, who criticised his "discourteous and incendiary language" and accused him of a pre-conceived belief that the documents were "a sham".

But Lord Pannick also argued that the judges didn't necessarily have to conclude that Mr Johnson's motives were "malign". They could just decide that its effect and impact were against the law, whatever the prime minister intended.

What did the government say?

Sir James Eadie QC, representing the government, said it was "untenable" to accuse it of trying to obstruct Parliament.

He said the government had a right to create "a clear space when it is not subject to the daily grind" to prepare for a Queen's Speech - which would set out Mr Johnson's new government's plan for legislation - and to tackle Brexit issues.

Lord Keen QC, also representing the government, said it was "forbidden territory" for judges to intervene on political arguments about when and how Parliament is suspended.

Image copyright PA Media Image caption Government lawyer Lord Keen said campaigners were drawing the judges into a "minefield"

He said there was no law setting out the length of the prorogation of Parliament, and instead the length of each session was set by constitutional convention.

Courts "must not cross the boundaries and intrude upon the business of Parliament" or they would be walking into an "ill-defined minefield", he said.

Who will decide the case?

Of the 12 judges on the Supreme Court, 11 will rule on this case - that way there can't be a split decision.

Most of the judges are English, two are Scottish, while one is from Northern Ireland and one from Wales.

Image copyright PA Media Image caption Supreme Court president, Lady Hale (centre row), leads the 11 judges who will decide the case

The president of the court, Lady Hale QC, is one of three women at the court. A former academic and public servant, she has had a career of pioneering judicial posts, becoming the first female Law Lord and Supreme Court judge.

As the case came to a close, she spoke for everyone watching when she said: "None of this is easy". But she said the judges would produce an answer "as soon as we humanly can".

What happens now?

The justices meet in a room. The most junior justice is, by convention, asked to give his or her view first. Lord Sales QC is the most junior.

The justices can all write their own judgements, or there can be an agreement that one justice will write a judgement with which the others will agree.

Judgements are normally handed down on a Wednesday morning. One judge normally reads a short five-minute summary of it in open court.

Full copies are made available at that point on the Supreme Court website together with a shorter press summary.

What options do the judges have?

If the government wins, then nothing changes: Parliament remains suspended until 14 October. But things could get complicated if they decide Mr Johnson acted unlawfully.

In documents submitted to the court, the government said it could see three options if the court ruled against it - and in some scenarios, it might just suspend Parliament all over again.

The court might rule that this suspension was unlawful, but their reasons might leave open the possibility of proroguing Parliament for the same time period in a different, lawful way. The judges could decide that the only lawful option is for the prime minister to recall Parliament before 14 October. Lawyers for Mr Johnson said he would comply, but it would require "extensive arrangements" to draw up a new Queen's Speech and get ready for the ceremonial State Opening of Parliament. The judges could declare the suspension was unlawful, and therefore Parliament remains in session as if it had never stopped. The government said it might still be able to consider suspending it again.

But Lord Pannick said all the judges needed to do was declare the suspension unlawful. The prime minister would not have to take any action and the Speakers of the Commons and Lords could decide how to proceed.