Hervé Falciani, a 40-year-old French-Italian, was arrested in Barcelona in July 2012 after he arrived by boat from France.
Switzerland asked for Falciani to be extradited to face charges of violating Swiss banking secrecy laws and revealing industrial secrets.
But Spain's National Court denied the request on the grounds that violating banking secrecy laws is not punishable as a criminal offence in Spain.
The court also argued that Falciani cannot be accused of revealing industrial secrets since the information he disclosed was given to the "competent authorities" and it was "related to illegal acts carried out through this bank which cannot be penally protected".
Spanish prosecutors had opposed Falciani's extradition on the grounds that he was helping authorities investigate tax fraud and because banking secrecy was abolished in Spain in 1977.
"We can't punish people who, when they observe criminal conduct where they work, denounce it to the authorities," Spanish prosecutor Dolores Delgado said during Falciani's extradition hearing last month in Madrid.
Falciani collected data on at least 24,000 customers of HSBC's Swiss subsidiaries from 2006 to 2008, while he worked in the bank's information technology development unit in Geneva.
He then passed on the data to French authorities.
The files, which were subsequently relayed by French investigators to their counterparts in the United States, Spain, Italy, Greece and several other European Union countries, led to a raft of prosecutions.
During his extradition hearing Falciani said his intention was to raise the alarm about the bank's activity and denied he sought to sell the information as alleged by Swiss officials.
"Never, in no instance," he said when asked if he had received any money for turning over the files to the French authorities.
He told the court he obtained the files from colleagues and said the information was so abundant that "if printed, it would fill an entire freight train."
Spain's National Court ordered Falciani's conditional release from jail pending his extradition hearing in December after the Spanish authorities argued he was cooperating in several European countries in investigations into tax evasion, money-laundering, corruption and terrorism financing.
Members of Spain's grass-roots "Indignant" movement against corruption and economic inequality had called for his release, seeing him as a hero.
Falciani fled to France from Switzerland in 2009 while he was under investigation by HSBC.
US officials then warned him he was in danger and advised him to go to Spain, Falciani said in a lengthy interview published in daily Spanish newspaper El Pais last month.
"They told me that the only safe place in Europe would be Spain, which had used my information with success in important cases," he said.
Story continues below…
"They thought it would be very unlikely that Spain would approve my extradition to Switzerland."