Unprecedented levels of secrecy in criminal trials are compromising the principle of open justice, lawyers say, and placing journalists at increasing risk of prosecution for reporting cases.

Cases involving allegations of torture by Pakistani intelligence officials, and suggestions of collusion by the British authorities, are affected by the secrecy rulings.

One of the cases concerns the Guantánamo Bay detainee Binyam Mohamed against whom terror charges were dropped last year. Intelligence chiefs are alleged to have pressed the foreign secretary, David Miliband, to suppress publication about the alleged activities of US and British officials in the case of the 31-year-old Ethiopian, who claims he was tortured in Morocco and Afghanistan.

In another case, Rangzieb Ahmed, a convicted al-Qaida member, says that in Rawalpindi, in 2006, he was beaten, whipped, deprived of sleep and had three fingernails extracted by members of Pakistan's Inter-Services Intelligence Agency before interrogation by MI5 officers.

Two high court judges last week said they wanted to release the full contents of a CIA file on Mohamed's treatment but they held back seven paragraphs after Miliband argued that it could compromise intelligence sharing with the US.

"The increase in the number of in camera hearings and closed judgments has raised a number of issues," Lord Justice Thomas said in the high court's written ruling last week.

Journalists trying to cover these cases are being placed in an increasingly precarious position. In one case a reporter was threatened with arrest for an article in which he wrote of evidence heard in public but given in a criminal trial that was partially heard in secret. He was told he might be arrested and that he and the defence barrister should "not leave the country". The prosecution mistakenly thought he had used material heard in secret.

Last month the Times faced prosecution for its reports about the conviction of the Chinese dissident Wang Yam for murdering the millionaire author Allan Chappelow for money. The case, thought to be the first murder trial held in secret for national security reasons, led to two journalists being referred to the attorney general for contempt of court, described by the judge in the case, Justice Ouseley, as "an urgent and serious" matter.

Lawyers say the approach of the court to the Times article, which the attorney general's office is now reviewing, is controversial. "Speculation [in the article], whether accurate or inaccurate, which purports to reveal the matters which were considered in camera ... may itself be a contempt of court," Judge Ouseley said.

A lawyer involved in secret hearings but not wishing to be named said: "How can speculation about what happens at an in camera ruling be held in contempt? If you want to stop speculation, then justice has to be completely open. It's natural to speculate. You can't have it both ways."

The rules on reporting secret or protected information, covering trials held in secret for national security concerns, fall under public interest immunity. Although the government does not keep records of the number of applications for criminal proceedings to be heard in private under the immunity system, increasing numbers of prosecutions under anti-terrorism laws and the use of special courts are making it harder for the press to cover many trials.

"It does feel as if civil liberties are under serious threat by these in camera rulings and restrictions on what lawyers and the press can and cannot say," said Tayab Ali, a solicitor. "Even when we think something is in the public interest we are prevented from reporting it or else face the risk of arrest."