Today’s hearing at the High Court before Lord Justice Beatson and Mr Justice Kenneth Parker was interesting, and not just because of the order they made. But let me turn to that order first.

The court has ordered that until a further hearing next Friday, August 30th, the government and the police may not inspect, copy, disclose, transfer, distribute (whether domestically within the UK or to any foreign government or agency) or otherwise interfere with the material obtained from David Miranda under Schedule 7 of the Terrorism Act 2000, save (1) for the purposes of protecting national security, including protecting lives and preventing the diminution of the UK’s national security capability; and (2) for the purposes of investigating whether David Miranda is or has been concerned in the commission, preparation or instigation of acts of terrorism.

David Miranda’s solicitor today called that a “partial victory” – but if it is in any sense a victory, it’s only a small one. I’m not surprised she mentioned the possibility of appeal. In truth the government has got most of what it wanted, and has preserved its ability to inspect the material, to copy it and to share it with American intelligence agencies, so long as it’s acting “to protect national security”. The ability to use the material to prevent “the diminution of national security capability” also seems a very wide power to use the material to protect GCHQ’s policy aims and interests.

Matthew Ryder QC, for David Miranda (who he said was “working with journalists”), wanted an order restraining any inspection or use of the material at all for 14 days, arguing that there was no evidence before the court that such a delay would prejudice national security. He argued that the government had been aware since June that the Guardian had access to material like this, and had not suggested to the Guardian that immediate inspection was needed, or invoked any legal powers to do so.

Nothing had changed in the last few days, he said, to increase the threat to national security caused by the leak of the material. It’s common in proceedings challenging the legality of a search warrant, he argued, for the courts to order non-inspection pending resolution of the challenge (Kenneth Parker J replied that it depended on the circumstances of each case).

If these submissions had succeeded, the police and government would have had to stop working on the “Miranda material” altogether, and then had to return David Miranda’s portable hard drive within 7 days of having seized it.

Steven Kovats QC, representing the Home Secretary, told the court that the material had already been inspected and that continuing inspection was needed. He accepted there was currently no evidence before the court supporting the “national security case” behind that claim, but said the government would be producing evidence as soon as possible, and that the balance of justice required it be given a chance to do so before an order is made preventing inspection. He disputed the contention that what was seized was “journalistic material” and argued that David Miranda can have no right to confidentiality in what he called stolen documents.

Kovats argued for inspection to be permitted for the purposes of criminal investigation, and protecting national security.

Jonathan Laidlaw QC, for the police, told the court that the material already inspected consisted of tens of thousand of pages, the disclosure of at least some of which would be “gravely injurious to public safety”. He argued that stopping inspection now would in effect be “final”, since it must be returned this weekend: there is no power to extend the 7 day examination period under Schedule 7, he said. He opposed any order narrowing the purposes of inspection – he said there was risk in doing so before the police had been able to examine all the material.

An especially interesting short debate took place about whether the material can be copied – or “imaged” – by the police. This was because Jonathan Laidlaw’s “finality” argument seemed to imply that the expiry of the 7 days period meant nothing could be available for the police to examine thereafter. Not necessarily so, argued Matthew Ryder: the material could be copied so that, after its return, and after the 14-day pause in inspection he sought, the police could later (if the court lifted its order) go back to inspect the copy material again. If this was not right, he argued, then the police could seek some other form of court order so as to inspect their copy; or if need be his client would consent on a voluntary basis to the police’s doing so. Kenneth Parker LJ was clearly unhappy with the idea of a voluntary agreement as the legal basis of police action (agreement could be withdrawn at any time, he said) but seemed to indicate he thought the material could lawfully be copied for later inspection – and on that basis all parties seemed to agree that was the position.

I find that a bit surprising, to be honest. I think Jonathan Laidlaw’s “finality” point suggested he thought copying for later inspection was legally doubtful; and I think it must be. Otherwise, what would be the purpose, in this case, of the 7 day limit? Matthew Ryder’s concession, if it was one, must have been tactical: perhaps getting the material back is more important to David Miranda than stopping the authorities (who by now already have a rough idea of what he has, or had, in any event) from keeping it. And conceding that a copy can if necessary be inspected later served, in my view, his case that a complete pause on inspection could “safely” be imposed now.

The concession was in any event arguably a very limited one: if inspection were restrained today but then later ruled lawful, Ryder was arguing, then the “finality” point could be met by later inspection of a copy. But I wonder what a court’s view would be if this right to “copy and keep” were seriously contested in another case.

Finally, Matthew Ryder argued that allowing inspection to continue would in effect make challenging the use of Schedule 7 pointless, at least in a case involving journalism. Once inspection resulted in sources being compromised, confidentiality could not be got back.

The order, then, denied David Miranda most of what he wanted, and gave the government everything it asked for – the words about the diminution of national security capability were lifted from Steven Kovats’ submissions – except the right to inspect the material for the purposes of criminal investigation. This may be of concern to the police. But I think tonight, government and police lawyers may be asked to think hard about exactly what “investigating whether David Miranda is or has been concerned in the commission, preparation or instigation of acts of terrorism” allows them to do. Arguably that may cover some of the same things they’d like to do as part of a criminal investigation – in which case, the court may not have narrowed  what they can do as much as it first appears.

But the order does cut down what can be done with the material between now and Saturday, and then next week. Schedule 7 paragraph 11(2) provides that

An examining officer may detain the thing—

(a) for the purpose of examination, for a period not exceeding seven days beginning with the day on which the detention commences,

(b) while he believes that it may be needed for use as evidence in criminal proceedings …

which suggests that in fact, Jonathan Laidlaw QC’s “finality” argument was misconceived, at least if it’s possible for criminal proceedings to be commenced in the next day or so. In any event, today’s order effectively scrubs out the power in paragraph 11(2)(b) as far as this case is concerned.

Matthew Ryder got on his feet to question whether the second “saving” in the order – the exemption for “investigating whether David Miranda is or has been concerned in the commission, preparation or instigation of acts of terrorism” – was necessary. He made the point that this was not asked for by either the Home Secretary or the police. The judges’ reaction to this was interesting.

Beatson LJ initially responded by saying that unless this saving was present, the police would be in a “Catch-22 situation”, being unable even to produce evidence on the national security points they want to make, and that at the next hearing ‘”we’d have a black hole”. But Kenneth Parker J in effect corrected him, saying the purpose of the saving was not to allow evidence to be produced in these proceedings but so as not to defeat “the central purpose of the legislation”. Beatson LJ in effect deferred to that.

This was a fascinating exchange, and I’ll be interested in how the judges deal with this in their reasoned judgment, once it’s available. My initial reaction was to think Kenneth Parker’s reasoning unduly favourable to the government side; but on reflection, perhaps he’s right. It would be odd if, seizure not having been ruled unlawful, inspection were permitted to continue by the court but not for the purpose laid down in legislation.

Two more things are worth reporting. First, Steven Kovats made clear that the Home Secretary wants the proceedings heard in public as far as possible, but that she will consider whether to make a “closed material procedure” application under the Justice and Security Act 2013, and will make clear next week whether she intends to do so.

Secondly, the course the case will take from now on. The court will give its reasons for today’s order tomorrow if possible, and Matthew Ryder may well seek permission to appeal. Then, crucially, David Miranda’s things will be returned to him by midnight at the end of next Saturday. Surprisingly there was a little discussion in court of when the 7-day deadline expires before this was agreed (but to be fair to the government side they were not arguing for another day). Presumably whatever material is capable of being copied will be copied before then, so inspection can continue for the purposes permitted by the order. And there may be an appeal early next week.

The government and police will have till next Tuesday or Wednesday to produce evidence to the court in support of their claims about national security; then a further, fuller hearing will be held next Friday about whether the interim order should continue, or else be lifted or varied pending the hearing of the full judicial review. All parties agreed today that the underlying, substantive legal challenge should be considered on a “rolled up” basis – in other words, in one big hearing covering the technical application for permission for judicial review and the actual judicial review itself (permission and JR itself effectively being merged). That’ll probably happen over 2 days sometime late in September or in October.

Some interesting legal questions are raised by the argument in today’s hearing. The restrictions on inspection presumably apply to a copy of the material as they apply to the original; otherwise, the purpose of today’s order could easily be defeated. It’s worth highlighting the issue, though, because the “copy and keep” theory that seemed uncontroversial today, if correct, would otherwise legally decouple the copy from the original at least for the purposes of time limits.

More fundamentally: on what basis do the police and government have any legal right to use this material for any purpose at all, beyond those laid down in Schedule 7? David Allen Green asked me earlier whether I think the injunction goes further than the power to detain contained in Schedule 7 paragraph 11 – and I think it does; the court has scrubbed out paragraph 11(2)(b) but has in effect inserted a new extra-statutory power to inspect it for national security purposes.

I’m not surprised by the outcome, though. The police and government have lost the ability to inspect this material for criminal investigation purposes outside whatever’s necessary to determine whether David Miranda is concerned in “terrorism” within the meaning of the 2000 Act; and (interestingly without any argument in court today) they seem to have lost the ability to retain David Miranda’s things beyond the weekend if there are criminal proceedings. But they have most of what they wanted, and David Miranda got very little, really.

Had no injunction been sought and no undertakings been given, the “Miranda material” could have been inspected until Saturday night for the statutory purpose for which it was kept. It still can be, after today’s hearing. It can also be copied and shared with foreign agencies for national security purposes (with no apparent need to seek assurances about their use of copies of the material), and it seems any copy can continue to be worked on after the original material is returned. In some ways the government might even feel its powers to work on the material seem wider tonight then they did this morning.