A terrorism suspect who went on the run disguised in a burqa has won a surprise legal battle with an appeal court ruling that dealt a major blow to the government's reliance on secret justice measures in cases of national security.

Control orders that had been imposed on Mohammed Ahmed Mohamed and a second man, who can be identified only as CF, were quashed after the court ruled that the government should not have been able to answer allegations of serious wrong-doing behind closed doors.

Both men were detained in Somaliland in 2011 during an operation in which British forces appear to have been involved. They were allegedly beaten, subjected to mock execution, and then flown to the UK against their will in circumstances that their lawyers say amounted to a "rendition" operation. On arrival they were put under control orders.

When the pair challenged those orders on the grounds that the government had been involved in their mistreatment, government lawyers relied upon a practice known as NCND – neither confirming nor denying the truth of the allegations in open court – and were permitted to present their full case in closed court.

On Friday Lord Justice Kay criticised the high court's acceptance of NCND, which he described as a policy "lurking just below the surface".

It was not a legal principle and needed to be justified, he said.

"It is not simply a matter of a governmental party to litigation hoisting the NCND flag and the court automatically saluting it," he said. "I do not consider that the appellants or the public should be denied all knowledge of the extent to which their factual and/or legal case on collusion and mistreatment was accepted or rejected. Such a total denial offends justice and propriety."

Kay also ruled that the control orders had been unlawful because the Home Office had not disclosed all relevant information when it asked a judge to issue them.

The appeal court ruled that the case should be sent back to the high court, which should reconsider the original challenge to the control orders.

CF's solicitor, Tayab Ali, said: "I am delighted that the court of appeal has vindicated our concerns over the manner in which this control order was imposed. Crucially, in rejecting the government's over-reliance on the 'neither confirm nor deny' policy, this judgement will assist those seeking to expose serious wrongdoing on the part of the authorities."

A Home Office spokesperson said: "We are disappointed by the court of appeal's decision and are considering whether to appeal."

Both men are British citizens of Somali descent who are alleged to have been involved with al-Shabaab, the Somali militant group that carried out the attack on Nairobi's Westgate shopping mall last year. Their wives and children are in Somalia.

The identities of both men had been protected by anonymity orders, as neither has been convicted of an offence, but Mohamed's order was lifted when he went on the run.

Mohamed was assessed to be linked to a group said to have received terrorism training from Saleh Nabhan, a leading al-Qaida figure suspected of involvement in the 1998 US embassy bombings in east Africa. He is also said to have received terrorism training from, and to have fought for al-Shabaab, and is accused of helping other British men slip into and out of Somalia.

CF travelled to Somalia in 2009, where he too is said to have received training and fought alongside al-Shabaab. Mohamed is thought to have been helping CF leave the country when they were detained after travelling to the breakaway territory of Somaliland.