Behind genuine sympathy for the United States in its Iranian agony and public endorsement of President Carter's tactics, there is this consensus among Saudi leaders: what has happened in Tehran is further evidence that Uncle Sam is on the run, retreating throughout the world.

They view this not with maliciousness but with alarm. This underpopulated, fabulously rich kingdom of incalculable stragetic importance is in an anxious mood. While all Saudis from taxi drivers to princes were stunned when the Grand Mosque in Mecca was attacked by religious fanatics, leaders here also were shaken when their supposedly client state of North Yemen made an arms deal with Moscow.

Those two unwelcome surprises intensify a long-term sense of peril. Outflanked by radical Arab governments now that the shah is no longer in Iran as a well-armed balancing force, Saudi Arabia approachs a decade when Russia will become a net energy importer and will be casting eyes on Saudi oil.

The strength and will of Washington, therefore, are vital to Riyadh. That in turn leads to ambivalence here over Carter's management of the Iran crisis.

Except for dismay over freezing Iran's assets, there is no criticism of specific U.S. decisions. Rather, the Saudis are relieved that precipitous military action did not inflame all of Islam against their American friends.

The ambivalence is expressed quietly in apprehension over what the Iran crisis suggests the president might do if this nation's fate were at stake. We all watch developments in Tehran, one member of the Saudi government's inner circle confided to us. And we wonder whether Carter will act firmly when the time requires it.

The doubt stems from dissatisfaction here with Carter's foreign policy. All Saudi officials begin with the grievance that the president has reneged on his commitment for a Palestinian homeland. But less publicly, there is a laundry list of complaints (particularly among the Saudi military) about U.S. policies not related to Israel: Angola, Taiwan, the Horn (Cape of Africa) -- and, of course, Iran.

Whatever Saudi troubles were with the shah, he is yearned for in comparison with Ayatollah Khomeini (described privately by one Saudi prince as fanatical, vindictive, senile). The overriding question: are Khomeini's preachments finding fertile soil in Saudi Arabia?

There is no doubt of the mullahs' impact in the oil-producing Eastern Province, heavy with Shiite Moslems attracted to Khomeini's claimed international leadership of the sect. Recent unpublicized demonstrations there by Shites (some carrying machine pistols) drew a quick response from the National Guard, the Bedouin light infantry brought in to replace the police. The guardsmen opened fire, and some 15 demonstrators died.

This had no direct connection with the attack in Mecca by extremists belonging to the country's Sunni Moslem majority, except for reflecting the magnetism throughtout the region of Islamic fundamentalism, particularly among youth. That the world's most conservative social system is attacked by militants seeking a return to the 14th century is viewed by the regime as an aberration not likely to be repeated.

Yet there are two disturbing elements. first, some National Guardsmen, including a few officers, belonged to the Mecca terrorist band. Second, if the Mecca onslaught took Saudi intelligence by surprise, how can anybody be sure this will not be repeated?

On top of this comes North Yemen's arms deal with Moscow, after earlier this year receiving U.S. arms (at Saudi urging) to cope with aggression by Marxist South Yemen. Saudi officials made clear to us they cannot tolerate the entire Yemen unified under communist control, whether by conquest or alliance.

Western military observers believe Saudi troops, particularly National Guard units modernized under U.S. Army guidance, would make short work of the Yemeni. But a country of only 4.5 million to 5 million Saudis (out of a total population of 8 million) has restricted military options. There is not even a contingency for coping with leftist Iraq's huge army.

Prudent use of the Saudi treasury for community development can mollify the Shiite minority and certainly prevent a Saudi revolutionary climate on the Iranian model. But failure of subsidies to develop a steadfast ally in North Yemen points to the limits of even unmeasured wealth. Nor can money satisfy the Russian bear's oil lust in the 1980s. Only the U.S. alliance can ultimately protect Saudi oil, and that is why Jimmy Carter's performance on Iran is watched with anxiety from Riyadh. w