Judge Eloy Velasco of Spain's National Court said the suspects include 7 Romanians and 2 Spaniards, who allegedly fraudulently extracted money from ATMs in February 2013.
The judge said there was evidence the suspects belonged to an international criminal organization that also laundered money and took part in credit card fraud.
Velasco said the cash extractions were perpetrated on a global scale and are linked to 8 hackers in the United States who penetrated the security system of a company that handled an Omani bank's card payments operations.
Access code numbers were distributed by the hackers to cybercriminals around the world who made 34,000 cash extractions in 23 countries within a space of 13 hours, the court statement said.
Authorities in the United States calculated that $45 million were stolen, making it one of the biggest heists in the 20th century.
The Madrid gang allegedly took part in the theft, using received codes to extract $390,078 from ATM's in the early hours of Feb. 20, 2013, the judge said.
Velasco said the suspects had also raided a cash dispenser in a similar manner in December 2012.
U.S. secret services led Spanish police to the suspects, most of who were arrested in December.
Seven of the hackers behind the thefts were arrested in New York in May 2013 and the presumed ringleader of the gang was murdered in the Dominican Republic, according to US police. All of the hackers were U.S. citizens of Dominican ancestry, the statement said.
For the latest tech news and reviews, follow Gadgets 360 on X, Facebook, WhatsApp, Threads and Google News. For the latest videos on gadgets and tech, subscribe to our YouTube channel. If you want to know everything about top influencers, follow our in-house Who'sThat360 on Instagram and YouTube.