Foreign Minister Jorge Castaneda announced today that Mexico will not permit the shah of Iran to return to exile here.

At a press conference, the foreign minister said Shah Mohammad Reza Pahlavi's arrival here would be contrary to the "vital interest" of Mexico. The shah's current 6-month visa exprires Dec. 9 and Mexico will not renew it, Castneda said, hence "there is no sense in the shah's returning to Mexico now.

Egyptian Ambassador Ashraf Ghorbal said in Washington that Egypt's invitation to the shah still stands and President Anwar Sadat is prepared to send his personal plane for the exiled Iranian.

["Our invitation is still there. Our desire to help the United States is still there," Ghorbal declared. Sadat has renewed the invitation more than once since the shah's initial stop in Egypt on leaving Iran in February. Ghorbal said that on Sadat's instructions he personally renewed the invitation on Nov.9 but the shah was too ill to travel.]

The Mexican foregin ministry said Ambassador Hugo Margain in Washington has informed the shah's family and representatives in New York of the decison. The shah, after successful removal, of a gallstone, reportedly had planned to leave New York early Friday for return to his exile residence in Cuernavaca.

Castaneda's announcement represents a total reversal of Mexico's position, reaffirmed only yesterday, that the shah would be permitted to return on a new visa.

"The situation has radically changed. The world confronts a real crisis," said Castaneda. "One of the major aspects of that crisis is the shah himself."

Castaneda gave no more specific reason for the Mexican change of mind.

He did say an aspect of the crisis he referred to was the seizure of the U.S. Embassy and hostages in Tehran. He called that "an act which Mexico energetically condemns as a flagrant violation of one of the oldest and most respected international norms."

Although high Mexican officials for the last two weeks have said repeatedly that the shah would be received in Mexico if he chose to come there after his treatment in New York, persons close to President Jose Lopez Portillo said they believe the Mexican president had not made that decision wholeheartedly.

According to one official it was understood here that Mexico's promise to readmit the shah was a condition for the United States issuing him a visa to vist New York for his treatment a month ago.

Knowledgeable persons here believe that the Mexican president's sudden refusal to accept the shah may reflect concern over unfavorable publicity and fear of terroist reprisals. The latter concern stems from the increasingly frenetic calls for holy war echoing from Iran.

Press reports here have severely criticized what they call the Mexican government's bowing to pressure from former secretary of state Henry Kissinger, who is attributed with having asked the Mexico government to admit the shah here in the first place.

One person present in a meeting with Lopez Portillo last week said that during the conversation the subject of Egypt's open invitation to the shah was raised. "With a deep sigh the president responded, 'I hope so," this person said.

The government clearly did not like critical reports in the press about the shah's alleged investments in Mexico and about his alleged bribery of Mexican officals.

One of Mexico's most widely read columnists, Manuel Buendia, wrote in a front-page article in the daily paper Excelsior yesterday that France had now also approached Mexico about its granting asylum to the deposed emperor Bokassa of the Central Africa Empire.

Although a spokesman for the Mexican government and the French Embassy here denied this, Buendia said the Mexican government turned down the request to harbor this man, "accused of murdering children."

Last week the rightist former dicator of El Salvador, Gen. Carlos Humberto Romero -- overthrown by a moderate military junta last month -- arrived on a tourist visa and is now seeking a residence permit.

"It would appear that Mexico has decided to turn itself into a backyard where the big powers can simply dump their throwaways," the angry Buendia wrote in Excelsior.

Mexico has a long tradition of receiving political exiles of whatever political belief and is home to Latin Americans on the outs, whether of the left or the right.

"Of course we are not alone in the world," a high government official commented yesterday, "but it seems that Mexico is burdening itself too much with other people's problems."

In apparent anticipation of the shah's return, Mexico had closed its embassy in Tehran three weeks ago. As an oil exporter, though not a member of OPEC, Mexico appaeared to be immune to economic pressures from Iran.

The shah's exile since last February took him first to Egypt, then the Bahamas, then Mexico and then to New York for treatment.