Several years ago, federal agents traveled to Moscow to enlist the help of their Russian counterparts in arresting one of the world’s most pernicious email spammers. They were rebuffed, a former American law enforcement official who was there said. The spammer, who used the pseudonym Peter Severa, was protected, probably by the Russian government, and could not be touched.

The agents went home and waited for their target to make a mistake.

Last week he did, traveling for vacation to Barcelona, Spain, where the agents who had been following him for years were ready. Early last Friday, Spanish police burst into the hotel room where the spammer was staying with his family and arrested him. Simultaneously, cybersecurity operatives from the Federal Bureau of Investigation and several private companies took down his online network of tens of thousands of virus-infected computers.

On Monday, the Department of Justice unsealed court papers accusing the spammer, whose real name is Peter Levashov, of wire fraud and unauthorized interception of electronic communications. Mr. Levashov, 36, is expected to be extradited to the United States.

Officials said Mr. Levashov’s arrest and the takedown of his network ended a vast criminal enterprise. For more than a decade, Mr. Levashov used his online empire to enrich himself and help others drain bank accounts and commit stock fraud, officials said. He has flooded computers with millions of spam email messages advertising counterfeit pharmaceuticals and remedies for erectile dysfunction, using subject lines like “No amorous failure risk.”