The threat of terrorism has become an unwelcome intruder in the upcoming, month-long World Cup soccer championships, one of the world's biggest spectacles.

Mexican authorities, including President Miguel de la Madrid, have hailed the May 31-June 29 tournament as a chance to display their country internationally in the flattering role of host to the world's most popular sport. Officials have predicted that thousands of foreigners will attend the matches and that hundreds of millions around the globe will watch on television.

With that in mind, the Mexican government has organized a security force of more than 30,000 police officers, soldiers and other agents to protect players and fans and prevent unruly or violent conduct. The security forces, some with special training, have been assigned to airports and to the 12 stadiums in nine cities in which 24 national teams will compete, including Mexico's.

"All these forces have been trained in nonviolence," said Ignacio Morales Lechuga, coordinator of the Interior Ministry's National Public Security Program. "Don't think we are preparing Rambo-type people."

His comment reflects the government's emphasis on maintaining a fiesta atmosphere for the tournament. Joao Havelange, president of the International Soccer Federation, also has played down the terrorist threat because, he told reporters here recently, everyone loves soccer too much to ruin the World Cup. As he spoke, several bodyguards stood nearby, the reporters said.

Mexico never has been the scene of a major terrorist attack, officials pointed out. But increased concern in many countries, particularly since U.S.-Libya confrontations this year, has placed terrorism in the public consciousness more clearly than at previous World Cup tournaments, including the last one, four years ago in Spain.

The Iraqi team, which became the first arrival last Tuesday, got an early feeling for the concern. The second day the Iraqis were at a hotel in Toluca, 40 miles west of the capital, a fire alarm went off, apparently accidentally. The alarm sent guests running from their rooms and prompted security agents to make a thorough, although fruitless, search of the facility, press reports said.

Morales said his government has received no concrete information of any plans to disrupt the tournament. But Mexico City authorities in recent weeks have been receiving several anonymous telephone calls a day announcing that a bomb has been placed somewhere, he said.

Only one has been found, he added, a 40-pound plastique bomb planted in a car parked on a street next to the U.S. Embassy on April 26. It was defused, and responsibility for it was claimed the next day by a group calling itself the Internationalist Simon Bolivar Command.

Despite Havelange's comments, sporting events have had a history of being targets for terrorists. The most infamous attack was by the Palestinians during the 1972 Munich Olympics in which 11 members of the Israeli team were killed.

Authorities here also have before them the memory of another kind of violence. A riot by British fans at a Brussels stadium last year led to 42 deaths and 300 injuries.

Closer to home, eight persons were killed and 70 injured last May when a soccer crowd panicked in an access tunnel at the stadium of the Autonomous National University of Mexico. And at the last World Cup in Mexico, in 1970, there were disturbances when the British team lost to Brazil in an elimination round in Guadalajara.

The Mexican government has worked out special arrangements with Britain to prevent a repetition. London has sent a list of known troublemakers to the Mexican authorities, who may not allow anyone on the list into the country. In addition, the British Football Association has issued "letters of introduction" to fans planning to travel to the World Cup tournament, certifying they have no record of violence in the stands.

"The Mexican authorities have welcomed these measures, and possession of a 'letter of introduction' should be an advantage at points of entry into Mexico and within the country," the association said in a statement to British fans.

The U.S. attorney general, Edwin Meese, offered Federal Bureau of Investigation help for the security efforts during a meeting with his Mexican counterparts last month in Cancun. Two FBI agents with experience at the Los Angeles Olympics in 1984 have visited Mexico to give advice, Morales said, but none is directly involved in security work.

More than a dozen French experts, here as part of a 10-year security assistance agreement signed last year, have been providing training and advice, and several dozen Mexican officers have gone to France for special training, Morales said.