Updated

A young chemistry student working as a volunteer to prepare a visit by the pope to Madrid has been arrested on suspicion of planning a gas attack targeting protesters opposed to the pontiff's stay, officials said Wednesday.

Pope Benedict XVI is due to arrive Thursday for a nearly four-day visit to celebrate World Youth Day, and a protest march was scheduled for Wednesday evening in Madrid.

A police official said the suspect arrested in the capital on Tuesday is a 24-year-old Mexican student specializing in organic chemistry. She would not say whether investigators believe the man was actually capable of carrying out a gas attack, and did not know if the man actually had chemicals for one.

He was arrested at a Madrid convention center where the hundreds of thousands of pilgrims coming to town for the papal visit are supposed to pick up their accreditation, the police official said on condition of anonymity in line with the department's rules.

An official with the visit's organizing committee said the Mexican was a volunteer working to help deal with the massive flow of people coming to Madrid. The official would not give her name, citing the church-run committee's policy.

More On This...

A total of 30,000 people from around the world are taking part in that organizing effort, 10,000 police are providing security in Madrid and organizers say they expect more than 1 million young pilgrims for World Youth Day, which started Tuesday and runs through Sunday.

The Mexican Embassy identified the detainee as Jose Perez Bautista and said he was from Puebla state, near Mexico City.

Police have 72 hours from the time of the arrest to bring the detainee before a judge at the National Court for questioning or to release him. A court official said he would appear before the judge Thursday at the earliest.

The official -- speaking on condition of anonymity in line with court policy -- said the detainee had been making threats over the Internet against people in Spain opposed to the pope's visit, and police who'd been monitoring his online activity ultimately decided to arrest him as the visit approached.

Police said in a statement released Tuesday night that officers who searched the detainee's apartment in a wealthy district of Madrid seized an external hard-drive and two notebooks with chemical equations that had nothing to do with his studies.

It said he tried to recruit people via the Internet to help him, and that a computer allegedly used for this purpose was among objects seized by police.

The man had planned to attack anti-Pope protesters with "suffocating gases" and other chemicals, the statement said. But it did not mention police having confiscated chemicals that could be used in an attack.

Mexican Embassy spokesman Bernardo Graue said consular officials had visited Perez Bautista in prison and described him as "relaxed" and in good physical condition as he waits to go before a judge. The Mexican officials did not ask him if he had in fact planned a gas attack, because interrogating him is up to Spanish authorities, Graue said.

Without knowing what chemicals and delivery system the man may have had, it is impossible to know what harm he could have caused on protesters marching in open air through the streets of Madrid, as will happen Wednesday evening, said Magnus Ranstorp, a terrorism expert at the Swedish National Defence College in Stockholm.

The suspect was in Madrid studying with Spain's top government research body, the Spanish National Research Council, and his office there was searched, the police statement said. The council confirmed the arrest but gave no immediate details on the Mexican.

Mexico's Autonomous University of Puebla confirmed that a man with the same name had completed an undergraduate degree in chemistry in 2009 and had expressed interest in doing graduate work in Spain.

"Both the name and the academic background match," said Rafael Hernandez Oropeza, the university's director of international relations. He said Perez Bautista had an 8.6 grade average out of 10, "which is pretty high."

He said the university had neither arranged the man's enrollment or any scholarship for study in Spain and was checking with the country's national science and technology council to see if it had done so.

Church organizers say the papal visit is costing about euro50 million ($72 million) to stage. Protesters complain the government is essentially spending taxpayers' money on the visit by granting tax breaks to corporate sponsors and perks such as discount subway and bus tickets for pilgrims.