A former MI6 worker has been given a 12-month jail sentence for trying to sell top secret material for £2m.
However, Daniel Houghton, 25, of Hoxton, east London, will be freed later on Friday because he has already spent 184 days in custody.
He had pleaded guilty to two offences under the Official Secrets Act and selling files to Dutch agents.
Houghton, who was arrested in March, had worked for the Secret Intelligence Service between 2007 and 2009.
He denied a charge of stealing materials, a plea which was accepted by the prosecution at the Royal Courts of Justice.
'Strange young man'
Houghton, who worked as a £23,000-a-year software engineer, had tried to sell copies of electronic files containing details of information-gathering software and staff lists to the agents in The Netherlands.
The Dutch authorities then tipped off MI5.
Piers Arnold, prosecuting, said: "It was a personal betrayal of these individuals with the potential, if it had fallen into the wrong hands, to compromise individuals' safety."
Judge Mr Justice Bean heard Houghton's account was that he was "directed by voices to do what he is said to have done in the charges".
Mr Justice Bean said he did not know if his claims were true but described him as a "strange young man".
He added: "If the material had found its way into the hands of a hostile power it would have done enormous damage and put lives at risk."
Agents from The Netherlands are understood to have bugged and filmed Houghton as he displayed the files and offered to provide them with lists of MI5 agents he had worked with.
The price was negotiated down to £900,000 and immediately after Houghton handed over the files on 1 March he was arrested while carrying a suitcase containing the cash.
Ginger beer wages
When police searched his flat they discovered paperwork marked "top secret".
A computer memory stick was found containing 7,000 files, while a hard drive with secret documents stored on it was also discovered.
David Perry QC, defending, said: "This was not an offence committed by a calculating ideologue to disclose material to a hostile sovereign state."
He said the Dutch agents contacted by Houghton "at first thought it was a hoax" and described him as a "naive young man who came across as a loner."
Police sources said Houghton appeared to have been motivated by greed.
One senior source said he had been living a "champagne lifestyle on ginger beer wages".
MI6, who vetted Houghton before employing him, has declined to comment on the security breach.