A court in Pakistan has upheld the detention of disgraced nuclear scientist AQ Khan and barred him from speaking out on nuclear proliferation.
But it also ruled that Dr Khan should be free to travel inside Pakistan.
Many Pakistanis revere the former head of the country's nuclear programme for developing its first atomic bomb.
But the scientist caused consternation around the world in 2004 when he confessed to passing on Pakistan's nuclear secrets.
The court challenge was brought by Dr Khan's wife seeking his release from de facto house arrest.
AQ Khan has been at the forefront of developing Pakistan's nuclear capacity
"At least now we have established the government has him under custody," Iqbal Jaffery, Dr Khan's lawyer, told reporters after the verdict.
The BBC's Syed Shoaib Hasan in Islamabad says he was referring to the insistence of various government agencies that they were not holding Dr Khan.
The court issued orders directing the government to allow the scientist to meet family or friends anywhere inside Pakistan whenever he wanted.
"He will be allowed to meet close relatives subject to security clearance, which is of paramount importance," the judgement said.
But it added that Dr Khan "will not convey, transmit, relay any comment or give interviews to any channel, news reporter, print or electronic media, in any manner whatsoever in respect of the issue of proliferation".
In recent months the restrictions against Dr Khan have not been so stringently implemented and he has been allowed to meet family and friends.
But correspondents say he has recently irritated the authorities by giving a series of media interviews in which he implicated institutions of the state in the nuclear secrets scandal.
Earlier this month Dr Khan said that Pakistan transported nuclear material to North Korea with the full knowledge of the army, which supervised a flight of centrifuges to Pyongyang in 2000.
Dr Khan, who has been treated for prostate cancer, was pardoned by President Musharraf in 2004 and has mostly remained in his Islamabad villa ever since, guarded by troops and intelligence agents.
In recent weeks he has retracted his confession.
The authorities have until now insisted he is not under formal house arrest, and restrictions on his movement are needed for his own safety.