WASHINGTON (AP) _ Saudi Arabia sought to ensure calm at the annual Moslem pilgrimage to Mecca by organizing an arms shipment to Iran through Israel, an Israeli author and journalist said Monday.

The idea that arms could be used to persuade Iran to desist from inciting unrest at Mecca was first broached in 1984 by Manucher Ghorbanifar, the middleman who later helped arrange the U.S. arms shipments to Iran's revolutionary government, said Shmuel Segev, author of an upcoming book about the Israeli perspective of the Iran-Contra affair.

According to Segev, who has covered the Israeli intelligence community for some 30 years and has already written one book about the Israeli-Iranian-U.S . relationship, the Saudi connection began when Ghorbanifar met Saudi billionaire Adnan Khashoggi in 1984 in Europe. Khashoggi has extensive ties to the Saudi royal family.

Segev, interviewed by telephone from Israel, said his upcoming book, ''The Iranian Triangle,'' is based on interviews with the key Israeli participants in the Iran arms affair, as well as documents he obtained through other sources.

His disclosure came as tensions in Mecca pitched following Friday's death of 402 people in a clash between Iranian pilgrims and Saudi security forces.

Ghorbanifar ''told Khashoggi about Iran's desperate need for arms,'' Segev said. ''And he also told him that he was a good friend of the man who has been appointed by (Iranian leader Ayatollah Ruhollah) Khomeini to organize the pilgrimage to Mecca.''

As many as 250,000 Iranians travel every year to the Saudi city, Islam's holiest shrine where tradition has it the Prophet Mohammed was born. Saudi Arabia has feared fundamentalist violence during the Hajj, or pilgrimage, ever since some 250 zealots took over the Grand Mosque in 1979 and disrupted the worshipping for two weeks of fighting with government security forces.

The man Ghorbanifar mentioned was Mehdi Kharoubi, the deputy speaker of Iran's parliament and president of the Martyrs Organization, Segev said.

Kharoubi and his brother Hassan, a close aide to Khomeini, later became two of the major contacts for U.S. officials seeking to gain the release of the American hostages held by Iranian-backed extremists in Lebanon.

Segev quoted Ghorbanifar as saying that through his friendship with Kharoubi, ''I think I can work out something to moderate tempers'' at the next pilgrimage.

Upon hearing this, Segev said, Khashoggi flew Ghorbonifar on his private jet to Riyadh and arranged an immediate audience with King Fahd.

''The king told Ghorbanifar he was ready tp pay graciously'' for calm at Mecca, ''and that's how the idea of arms to Iran was first born,'' Segev said.

Fahd said he could not send Iran U.S.-made arms without approval from the United States, and Ghorbanifar suggested that Khashoggi use his past contacts with Israel to arrange a shipment of Israeli arms instead, Segev said. Fahd approved the idea, he said.

Khashoggi had two Israeli contacts - U.S.-born arms dealer Al Schwimmer and former foreign ministry director David Kimche, whom the Saudi met in the 1960s when he was an operative of the Israeli Mossad spy agency in Paris, Segev said.

Both Kimche and Schwimmer later became instrumental in the U.S. arms shipments to Iran.

Khashoggi contacted the Israelis, and after some internal wrangling among Israeli officials, it was decided to ship Iran a boatload of weapons, Segev said. Schwimmer's partner, Yaakov Nimrodi, who was also an associate of Ghorbanifar, chartered a ship and brought it to the Israeli port of Eilat, Segev said.

The writer said, and Nimrodi confirmed in an interview, that an Iranian colonel was sent to Israel in the spring of 1985 to oversee the shipment in an operation code-named ''Cosmos.'' It was arranged that as partial payment, Iran would send back on the ship a Soviet-made T-72 tank it had captured from Iraq. The state-of-the-art tank was of great interest to Israeli and U.S. intelligence.

The deal fell through a day or two before the ship was to set sail for the Iranian port of Bandar Abbas when ''some faction in the Iranian leadership chickened out because they thought Israel's connection in the whole deal was too visible,'' Segev said.

In the meantime, Kharoubi, the pilgrimage organizer, undertook to ensure quiet at Mecca while Ghorbanifar sought another avenue for getting arms to Iran, eventually coming up with the U.S. channel.

Indeed, records show that the Saudi and Iranian foreign ministers exchanged visits in the summer of 1985 and the authorized number of Iranian pilgrims was increased from 100,000 to 250,000. Both years saw a mostly uneventful pilgrimage.