The pontiff is due to arrive Thursday for a nearly four-day visit to celebrate World Youth Day, and a protest march is scheduled for Wednesday evening in Madrid.
A police official said the suspect arrested in Madrid on Tuesday is a Mexican student specializing in organic chemistry, but did not give his name or age. Police said in a statement that officers who searched the detainee's apartment seized an external hard-drive and two notebooks with chemical equations that had nothing to do with what he was studying and a PC "allegedly used to recruit on the Internet."
The statement said he planned to attack anti-Pope protesters with "suffocating gases" and other chemicals.
The official spoke on condition of anonymity in line with police rules.
The statement says the suspect was in Madrid studying at Spain's top government research body, the Spanish National Research Council.
Church organizers say the visit is costing about euro50 million ($72 million) to stage. Protesters complain the government is essentially spending taxpayer money on the visit by granting tax breaks to corporate sponsors and perks like discount subway and bus tickets for pilgrims.
Officials at the Mexican Embassy in Madrid did not immediately respond to telephone and email messages seeking comment.