The head of Denmark's foreign intelligence unit, who was detained in December over allegations he was involved in classified information leaks, was released from custody on Thursday, public broadcaster DR reported.
An appeals court ruled there were no grounds to keep Lars Findsen in detention while investigations continued, DR said.
Findsen has denied any wrongdoing in a case that has rattled the Nordic nation.
The public prosecutor's office has said the case involves the leaking of highly classified information, but has not gone into further detail. Hearings have taken place behind closed doors.
The Eastern High Court's ruling on Thursday overruled a decision by a city court earlier this month to extend Findsen's custody. Prosecutors had argued that he might obstruct investigations, according to court documents.
The Eastern High Court issued a statement confirming it had overturned the lower court's decision, but did not name Findsen.
The court said it found "reasonable suspicion" that the unnamed defendant had violated the rarely used section 109 of the penal code, which includes treason for leaking state secrets and carries a maximum sentence of 12 years in prison.
Findsen's lawyer, David Neutzsky-Wulff, welcomed the decision to release him.
"We are extremely happy and grateful for the decision. This means that we can prepare the case while he is free and not sitting behind bars," he told DR.
(Reporting by Nikolaj Skydsgaard and Stine Jacobsen; writing by Jacob Gronholt-Pedersen; editing by John Stonestreet and Andrew Heavens)