Mr Levashov is subject to a US international arrest warrant and a Spanish court will hear whether he can be extradited.
Much of his alleged activity involved ransomware – blocking a computer’s access to certain information and demanding a ransom for its release.
Mr Levashov’s wife Maria told Russian broadcaster RT that the arrest had been made in connection with allegations that Russians had hacked the US presidential election.
She said Spanish police had told her the arrest was in connection with “a virus which appears to have been created by my husband and is linked to [Donald] Trump’s victory”.
However, Agence France-Presse news agency quoted a source close to the matter in Washington as saying that Mr Levashov’s detention was “not tied to anything involving allegations of Russian interference with the US election”.