Police found two letters dating from 2001 and 2002 offering to sell information about Spain's secret services to a Russian diplomat for 200,000 euros ($275,800), at the home of Roberto Florez in 2007, Madrid's regional court said in a ruling on Thursday.
There is no proof that he managed to sell the information, the court said, adding that Florez had attached confidential documents to the letters.
In the hands of a foreign power (the information) would have put national security at risk, the court said.
Florez, who worked at the CNI secret services headquarters from 2000, said at his trial that the letters were part of a secret service exercise.
(Reporting by Teresa Larraz; writing by Jonathan Gleave; editing by Robin Pomeroy)