CAIRO, AUG. 5 -- Saudi Arabian officials charged today that Iranian pilgrims who demonstrated at Mecca last Friday had planned to take over the Grand Mosque, Islam's holiest shrine, and force worshipers to proclaim Iran's Ayatollah Ruhollah Khomeini as their spiritual leader.

King Fahd of Saudi Arabia, in his first public comments on the violence that left more than 400 persons dead, vowed to protect Islam's shrines from "conspiracy" in a statement read on his behalf to the heads of delegations to the hajj, or annual pilgrimage to the Moslem holy cities of Mecca and Medina.

Fahd said the Saudi rulers would "never relent in the defense of our homeland and sacred shrines." He did not, however, mention the Mecca incident or single out Iran by name, and he took what was considered a conciliatory tone in saying, "We will rise above trivialities, hasten to do good and exert ourselves for reconciliation and fence-mending," the official Saudi Press Agency quoted him as saying.

According to officials in Mecca, who spoke to The Associated Press, Iranians interrogated by Saudi police in the wake of last week's clashes said that they had planned to take over the Grand Mosque, lock pilgrims inside it and force them to declare Khomeini the religious leader of the world's 850 million Moslems.

If there was resistance, the officials told AP, the Iranians planned to kill the chief clergyman of the mosque and then set fire to it.

Tehran radio reported today that the 87-year-old Khomeini has canceled all appointments for Thursday, the final day of the Moslem Eid al Adha celebrations. The radio gave no explanation for the cancellation. Khomeini was reported last year to have suffered a heart attack, and the state of his health is frequently the subject of speculation in western diplomatic circles.

Earlier today, the first Iranian planeload of survivors and bodies of Iranians killed in the Mecca clash arrived in Tehran. The plane carried 58 bodies and 35 survivors. Iran's official Islamic Republic News Agency (IRNA) quoted survivors as saying they had been fired at, beaten and taken away in livestock trucks and then beaten again, during and after the clashes with Saudi police in Mecca.

IRNA quoted one pilgrim, Sayyed Rahim Dezfuli, as saying that pilgrims were stoned from nearby buildings and shot in the streets and that the ambulances of the Iranian Red Crescent Society had also been shot at while attempting to aid the wounded.

The pilgrim said that Iranian women were the main target of Saudi police. The agency also quoted an Iranian whose body had been pierced by 40 fragments of a dum-dum, a soft-nosed bullet that explodes upon impact, which allegedly tore his spinal cord.

Another pilgrim, according to IRNA, said the injured were "transferred in vehicles used for carrying livestock" and that others died "due to lack of proper treatment . . . or because they were beaten up again."

Saudi Arabia has said from the beginning that the violence was fomented by Iran and that most of the 402 deaths occurred when pilgrims were trampled in an Iranian stampede. Iran has charged that Saudi riot police opened fire and blamed the Saudis and the United States for what it called a massacre.

Iran completed the second of three days of military maneuvers in the Persian Gulf and Strait of Hormuz. The commander of Iran's paramilitary Revolutionary Guards said Iran will deploy a submarine there and would use missiles to attack any enemy that provokes Tehran.

The AP reported that the submarine was shown on Iranian television and appeared to be about 20 feet long. Iran said it was built by the Revolutionary Guards.

IRNA quoted the commander of the Revolutionary Guards, Mohsen Rezaie, as saying the submarine would be deployed during the naval maneuvers, scheduled to end Thursday.

Today's announcement was the first time Iran has mentioned having a submarine in its naval fleet. The London-based International Institute for Strategic Studies lists no submarines in the Iranian Navy.

{Pentagon officials expressed surprise at the Iranian submarine announcement but said, "We have to add that to the list of threats," Washington Post staff writer Molly Moore reported. Officials said the gulf is generally considered too shallow for submarine operations.}

Rezaie said that, during the maneuvers, Revolutionary Guards were attacking mock targets with surface-to-ship missiles but that they would not be fired against vessels in the gulf "except for an untoward incident instigated by an enemy," IRNA reported. He said the maneuvers were being staged to increase Iran's ability "to confront plots of the United States."

On Tuesday, Iran said it was training the Revolutionary Guards to use speedboats to launch suicide attacks against U.S. warships that are escorting reflagged Kuwaiti tankers through the gulf.

In the wake of the mine explosion last month that damaged the reflagged Kuwaiti supertanker Bridgeton, which was being escorted through the gulf by U.S. Navy warships, eight U.S. mine-sweeping helicopters arrived yesterday on the Indian Ocean island of Diego Garcia. They will be transported to the gulf aboard the helicopter carrier USS Guadalcanal.