The Court of Appeal has cleared the way for the Government to apply for controversial secret court hearings as it faces being sued for damages by an IRA informant and Iranians subjected to asset freezing orders.
The court rejected challenges to the legality of new powers that enable Government ministers to defend themselves against damages claims while using secret hearings to prevent "sensitive material" said to relate to national security being revealed in evidence in open court.
What are known as closed material procedures (CMPs) - in which evidence is given with claimants and the public barred from court - were introduced by the 2013 Justice and Security Act.
Critics have condemned the closed hearings as "a serious aberration from the tradition of open justice".
But a total of five judges have unanimously agreed the secret hearings are lawful, provided they are "scrutinised with care" and discontinued if they become "no longer in the interests of the fair and effective administration of justice".
Leading appeal judge Lord Justice Richards declared: "A closed material procedure is a serious departure from the fundamental principles of open justice and natural justice, but it is a departure that Parliament has authorised by the 2013 Act in defined circumstances for the protection of national security."
The two cases in the landmark ruling include a damages claim being brought against Home Secretary Theresa May by IRA mole Martin McGartland.
A former agent of the Royal Ulster Constabulary Special Branch, the informant claims the security services failed to provide him with care for post-traumatic stress disorder and access to disability benefits after he was shot by the IRA and left unable to work.
Mr McGartland, 43, and his partner and carer Joanne Asher are suing MI5 for breach of contract and negligence over the "mishandling" of his case.
His lawyers contend Mr McGartland's claim for damages for personal injury does not pose a risk to national security and will not expose any aspect of his undercover work as an informant against the IRA.
Government lawyers told the court that an assurance of "secrecy forever" lies at the heart of the relationship between the British Security Service and its agents.
The west Belfast man's best-selling book about his experiences as an informant, 50 Dead Men Walking, has been made into a film.
In the second case, Ahmad Sarkandi and four other Iranians are suing Foreign Secretary Philip Hammond for damages under the 1998 Human Rights Act.
They say in 2010 they were "unlawfully" included, at the UK Government's request, in the European Union's restrictive measures regime.
The measures included freezing the assets of the designated individuals and restricting their travel on the basis that each of them was a "senior member" of the Islamic Republic of Iran Shipping Line (IRISL).
The measures were introduced under EU legislation directed at preventing nuclear proliferation activities in Iran.
IRISL and the five, among others, won their applications to the General Court of the European Union to annul their designations.
The five are now challenging the Foreign Office decision to propose their designation and claiming High Court damages for losses suffered as a result of the listing proposal.
In both cases, the Government obtained declarations from High Court judges under section 6 of the Justice & Security Act 2013 that it would be lawful during trial of the damages actions to consider sensitive material at closed hearings excluding the claimants, with special advocates present to protect their interests.
In the McGartland case, Mr Justice Mitting ruled secret hearings were justified because the case involved sensitive material relating to the training and the protection of security service "handlers" placed in charge of agents.
Mr Justice Mitting declared that closed procedures were "in the interests of the fair and effective administration of justice" and therefore permitted under section 6.
In Sarkandi, the Government said it would not be able to disclose its grounds of defence without causing serious harm to national security and intended to apply for closed hearings when sensitive material was under discussion.
Mr Justice Bean granted a section 6 declaration allowing closed hearing applications to be made.
In the appeal court, Lord Justice Richards said the court had been called upon to consider "at a relatively early stage" what was "the correct approach" to the new laws introducing closed hearings.
Upholding the High Court rulings in favour of closed hearings, he said "appropriate safeguards against inappropriate or excessive use of a closed material procedure are built into the provisions themselves".
The judge stressed in the McGartland case that he had read the High Court decision as going no further than "opening the gateway" to closed material proceedings being a "possibility", and he expected any application to use them to be "scrutinised with care".
At the full trial, the court would have to consider serving a summary of the evidence heard in private, and throughout the hearing there had to be compliance with the Article 6 right to a fair trial under the European Convention on Human Rights.
If the court considered at any time that a closed hearing was "no longer in the interests of the fair and effective administration of justice" it must revoke the section 6 declaration.
In the Sarkandi case, the judge said a judge in a previous case had made observations that "do not acknowledge as fully as they might the difficulties faced by special advocates in testing evidence that emerges in the closed material procedure, in circumstances where they cannot seek the instructions of the claimants on that evidence".
But the judge said the "general thrust" of the observations that a just result could be achieved "does not strike me as unduly sanguine", and Mr Justice Bean had not fallen into error in adopting a similar approach.