CAIRO, AUG. 1 -- Saudi Arabia said tonight that 402 people were killed during yesterday's clash between police and Iranian demonstrators in the Moslem holy city of Mecca. In Tehran, angry crowds reacted to reported deaths of Iranian pilgrims by storming the Saudi, Kuwaiti and French embassies, the Iranian state news agency said.

News agencies quoted Saudi state television as saying tonight that 275 of the dead were Iranians, 85 were Saudi security officers and 42 pilgrims of other nationalities. Saudi television said the clash had injured 649 people and broadcast film that it said showed Iranian pilgrims were to blame.

Iran, through its news agency and state radio, had earlier accused Saudi police of killing 200 Iranians with gunfire during a demonstration amid the annual hajj, or pilgrimage ceremonies in Mecca. Tehran radio said Iran has received the corpses of 60 of its pilgrims.

Saudi television quoted Information Minister Ali Hassan Shaer as saying that victims were trampled to death when Iranian pilgrims stampeded. He denied Iranian accusations that police had fired automatic weapons at the crowd. "Not a single bullet was fired," he said.

Iranian President Ali Khamenei called the violence in Mecca a "U.S.-designed plot," and Prime Minister Mir Hossein Mousavi said Iran would mobilize all its resources to avenge what he called a massacre.

{In Washington, the State Department said the charges of U.S. responsibility for the Mecca violence "are totally baseless, and the government in Tehran knows it. . . . Iran's false charges are designed to inflame passions and escalate tensions in support of Iran's political aims to destabilize the region."}

Independent accounts of the violence in both Mecca and Tehran remained sketchy. Mecca is closed to non-Moslems, and the Saudi government tightly controls information from the country. Few foreign journalists are permitted to work in Iran.

Witnesses in Mecca told The Associated Press that Iranian pilgrims began shouting slogans against the United States, the Soviet Union and Israel yesterday as they left a mass prayer ceremony. The Iranian leader, Ayatollah Ruhollah Khomeini, had called for demonstrations against "pagans" during broadcasts to Mecca on Tehran radio.

The demonstrators waved posters of Khomeini and burned cars and effigies of President Reagan, the witnesses said. Agence France-Presse reported from Islamabad that Pakistani witnesses, contacted by telephone in Mecca, said the violence had begun when an Iranian demonstrator hit a Saudi security officer with a broken soda bottle.

Saudi television said Saudi Arabia rejected Iran's account of the violence as lies. Shaer said the Saudi government would invite Arab and Moslem diplomats to view videotapes showing that the demonstrators were responsible for the casualties.

In Tehran, crowds smashed their way into the Saudi Embassy in response to radio reports of the deaths in Mecca, the official Islamic Republic News Agency reported. It said demonstrators, including families of those killed in Mecca, burned portraits of Saudi leaders, smashed windows and burned embassy vehicles before troops intervened.

A Saudi Foreign Ministry statement said Iranians had abducted four Saudi "embassy employes" when they sacked the embassy. Saudi Arabia was demanding their release, it said. The Iranian news agency had said earlier that no diplomats were in the building when the crowd attacked.

The crowd then marched on the Kuwaiti and French embassies, sacking them, the Iranian agency said. The French Foreign Ministry in Paris said its building had been stoned but said the crowd had not entered. Fifteen French citizens have been trapped in the embassy during weeks of diplomatic standoff between Paris and Tehran.

The Iranian account said demonstrators had stoned the Iraqi Embassy before security forces intervened to prevent their breaking in. Despite their nearly seven-year-long war, Iran and Iraq maintain diplomatic relations.

Pakistani pilgrims contacted by Agence France-Presse said calm had returned to Mecca today, AFP reported.

The riot in Mecca came as an estimated 2.1 million Moslems from around the world were in the city for the annual pilgrimage, which each able Moslem is called upon to make once. The pilgrimage has been a stage in recent years for confrontation between the conservative Sunni government of Saudi Arabia and both Sunni and Shiite Moslem fundamentalists.

Since the Iranian revolution, Iranian pilgrims have held demonstrations at each annual pilgrimage, and Saudi police have broken them up. Each year, Saudi Arabia has appealed for a stop to what it says have been political protests.

In November 1979, 250 fundamentalists seized the Grand Mosque, Islam's most holy site. During nearly two weeks of fighting during which Saudi troops eventually retook the mosque, 229 people were killed.

Islam split into Sunni and Shiite sects in the 17th century over the succession to Mohammed, the prophet of Islam.

The violence raised already heightened tensions in the gulf between Iran's radical Shiite government and the gulf Arab states, which are ruled by conservative Sunnis. Iran has sharpened attacks on Saudi Arabia and other allies of Kuwait, who it says have invited the U.S. Navy into the region in its protection of reflagged Kuwaiti oil tankers.

Iran today ordered three days of mourning for victims of the violence and declared Sunday a "day of hatred" against the United States, to be marked by a mass demonstration in Tehran. Ayatollah Hossein Ali Montazeri, Khomeini's designated successor, called on Moslems forcibly to take control of Islamic shrines in Saudi Arabia from the government there.

An Iranian Foreign Ministry statement, broadcast today by Tehran radio, said the violence demonstrated that the Saudi rulers were "un-Islamic." It called on Islamic scholars to "oust the Saudi rulers from the noble twin sanctuaries," the holy cities of Mecca and Medina.

In Iraq, the Revolutionary Command Council called for Iranians to be barred from Islam's holy shrines, Reuter reported.

Information Minister Shaer expressed Saudi frustration with Iran, saying, "The Saudi government has exhausted all means for cooperating wether directly or through intermediaries with the Iranian authorities." He added, "For a long time, we have turned a blind eye to violations of the laws of our country . . . not out of weakness but out of tolerance and concern for the safety" of the pilgrims.

Iran announced it was sending a delegation to investigate the violence, but it was not clear how the Saudi government would respond to its visit.

There had been a demonstration scheduled for Sunday in Mecca, in which more than 150,000 Iranian pilgrims were to have gathered to hear another address from Khomeini. But the Saudi Interior Ministry said today that it had repeated instructions to its security forces to ban "all gatherings, demonstrations and all types of processions."