By all normal yardsticks, shah Mohammad Reza Pahlavi is firmly in control of Iran despite the five-month-old cycle of violence that represents the greatest challenge to his authority in 15 years.

Yet, the very open-ended nature of the violence - and the deep-seated unrest, if not outright opposition, it masks - has prompted many Iranians to worry about the future of a government run by an unbending 58-year-old autocrat.

The real threats probably lie down the road, when Crown Prince Reza, now 18, will have to deal as an untested newcomer with increasingly complex problems of a nation of 33 million.

So far the shah's pampered army has performed efficiently, if often heavyhandedly, in such tasks as riot control against university students and religious demonstrators. That is no mean accomplishment since in the Third World the army is any ruler's power base.

Relatively little of consequence has actually happened except for two outbreaks of violence in the religious city of Qom and a kind of uprising in the northwestern city of Tabriz.

It took the religious opposition four months to mount demonstrations in the capital where most observers believe violence must be centered in any serious effort to dislodge the shah. Even then a massive show of army strength kept the disturbances and the casualities down.

Yet, there is an uneasy feeling here because no one seems to know where the slow motion crisis is headed.

The shah is said to believe that the protest movement - which lurches ahread in 40-day cycles corresponding to the Moslem mourning period - will blow itself out.

Opposition leaders, however, while admitting that the shah still has the upper hand, argue that he has lost the initiative and must learn to live with the demonstrations.

"Really, both the opposition and the shah are weak and caught in a dead end street with little apparent chance of compromise," said Medhi Bazargan, a leader of the Iran Freedom Party and a prominent opposition figure.

"That is a change since this is the first time that the shah has not been all-powerful," he added.

Even if his interpretation is open to dispute, the shah's behavior - and his government's - has done much to foster doubts.

If security police and army troops have learned to use tear gas rather than firing blindly into crowds, the government's public relations still leave much to be desired.

Newspapers give feast or famine coverage of opposition action. One day there is nothing, the next everytime someone so much as puts an elbow through a provincial window the incident is described in full.

Presumably such extensive coverage is designed to turn the public against opposition excesses, but this may be a questionable assumption.

Many persons believe that the government either has had a hand in some of the disturbances or purposely exaggerates their importance, apparently in the belief the middle class which owes so much to the shah will rally to his side.

Such assumptions are dubious at best. Bankers suggest that wealthy and middle class Iranians are prudently transferring funds abroad. The reasoning apparently is that the government may suddenly clamp down and prevent free transfers of funds abroad.

Nor does the government give any sign of acknowledging that many Iraniane may have genuine grievances, ranging from the quality of life to corruption in high places.

In recent times the shah has written off the troubles as the work of a Communist-inspired minority.

Yet, the government's inability to attract the loyalty of the middle class was conceded indirectly in an editorial which appeared in the government-control newspaper Kayhan International after the latest bout of violence.

Premier Jamshid Amouzegar in an interview mentioned a reaction against Western materalism as one of the strains and stresses which have contributed to the disaffection with the government.

He pleaded that more time was needed before Iranians could handle parliamentary rule. In 20 years, he noted, illiteracy had been reduced from 90 percent to 55 percent.

Such arguments do not always satisfy sophisticated Iranians.

A young businessman who claims to make half a million dollars a year remarked, "We're angry about the Tehran traffic when the shah is spending billions on military gadgets.

"We're angry about the pollution in the capital. Face it, everyone has got a complaint."

Put another yay, the broad transformation and disruption of Iranian society caused by the oil bonanza has turned out to be the road back for the opposition.

The opposition represents a tactical alliance of disillusioned academics, antiestablishment students, middle-class bazaar shopkeepers, known leftist and rightist guerrilla groups, old-time politicians and, especially, the Shia Moslem clergy which alone has the power to mobolize the masses.

Recently the shah has shied away from blaming the continuing disturbances, on the Shia clergy, who are, however, the principal instigators. This apparently reflects his hopes of patching up his worsening relations with them. Those relations were scarcely improved by the government's abject apology for sending troops into the compounds of two religious leaders in Qom.

Without illusions about the clergy's seeming inability to do more than generate demonstrations, the more thoughtful and Westernized opposition leaders are worried about the months ahead.

If the clergy accepts a compromise - involving, for example, toning down suggestive movie billboards or banning overly suggestive imported television films - there are serious doubts the faithful would follow them.

Any such disavowal, the pessimists argue, would also risk turning young activists away from Iranian and toward the extreme left and an armed guerrilla underground.

Although badly split among pro-Peking, Pro-Moscow and New Left wings, that segment of the opposition has never shied away from violence as the urban guerrilla activity of the early 1970s proved.

The guerrillas failed then largely because no segment of the public responded to them.

But in the words of a conservative bazaar merchants, scarely a representative of the extreme left, "then we could not understand them. But that is no longer true today."

Already some observers fear the Shah's crackdown has increased the pressure by leftist and rightist extremists on the moderate center of the opposition.

Ayatollah Ruohollah Khomeiny, the exiled Shia leader who has consistently called for the shah's overthrow from his exile in Iraq, seemed to be saying as much in an interview last month with French newspaper LeMonde which was widely distributed clandestinely.

Speaking before the May Violence he said the previous round of disturbances "foreshadowed a gigantic explosion with incalculable consequences.

Many Iranian opposition leaders take a less apocalyptic view of the situation. "There is still time left," a dissident lawyer said, "but the shah does not seem to be trying at all."

On paper at least, the shah and the moderate opposition have more to lose than gain by continuing the cyclical violence.