A former MI6 worker from London has said he was "directed by voices" after admitting charges of unlawfully disclosing top secret material.
Daniel Houghton, 25, of Hoxton, east London, pleaded guilty to two offences under the Official Secrets Act.
Houghton worked for the Secret Intelligence Service between 2007 and 2009. He has been remanded in custody.
He denied a charge of stealing materials, a plea which was accepted by the prosecution.
Royal Courts of Justice 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".
The judge said a prison term was "inevitable" and gave the prosecution permission to obtain expert psychiatric reports ahead of sentencing on 3 September at the Old Bailey.
Houghton had tried to sell copies of electronic files containing details of information gathering software and staff lists to Dutch agents for £2m.
The Dutch authorities then tipped off MI5.
Agents from the Netherlands are understood to have bugged and filmed him 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.
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 top secret documents stored on it was also discovered.
MI6, who vetted Houghton before employing him, declined to comment on the security breach.
Police sources said Houghton appeared to have been motivated by greed.
One senior source said he was living a "champagne lifestyle on ginger beer wages".