The shah has survived Ashura-his greatest test to date-but at the humiliating price of barricading his palace with tanks and troops and abandoning the capital to peaceful demonstrators demanding his ouster.

The symbolism of his isolation from his once respectful subjects during the two-day Ashura feast of Moslem mourning led a long-time observer to remark, "The end is now in sight but it is not near."

As so often the case in this nearly year-long crisis, once again there seems to be no immediate practical followup to this latest major escalation in Iran's slow-motion revolution.

But indications have begun to surface suggesting that the erosion which has eaten into the rest of Iranian society has started affecting the military, here as so often in the Middle East the main organized force.

The officer corps, long pampered by the shah, is now reported to be debating whether he has become a threat to national unity rather than its symbol.

As staunch authoritarians, the military will factor in fears that the now cocky opposition is rapidly radicalizing even middle-class Iranians who have long been willing to remain silent when they disapproved of what was happening.

All this was largely unthinkable only six weeks ago. Then the military carried out what can now be seen as a partial coup against the shah, apparently forcing him to remove a civilian Cabinet against this better judgment.

Now the military government doubtless would like to qualify, its boastful predictions of restoring law and order and bringing the moribund economy back to life.

The latest humiliation for the military was the compromise its leaders had to accept over security arrangements for the Ashura holidays.

Indicative of the gradual decline of the shah's once unquestioned authoritarian powers is the report by insiders that it was not the monarch, but the prime minister-Gen. Gholam Reza Azhari-who decided to pull back the troops from most of Tehran and hand the city over to the opposition.

In authorizing processions theoretically banned under the now 3-month-old martial law, the general also signaled his own weakness-he dared not risk the unity of his largely draftee army if ordered to shoot fellow Iranians.

All it took was a warning from three Moslem religious leaders that Moslem soldiers were not under any circumstances to shoot at fellow Moslems.

Even without the reiterated threat of escalating the conflict to armed resistance against the shah, there are enough reports about desertions of draftees and critical conversations among officers to worry the high command.

The carefully censored official news media have conceded on several occasions that soldiers have wounded their officers, presumably because of political differences.

Karim Sanjabi, the National Front opposition leader, felt confident enough this week to denounce the "Cossack mentality" of the army and insist it must become a "national army and not the agent of one person, one family."

He denied that the Front had encouraged desertions, but said, "it is inevitably happening and if it continues it will be very dangerous for the country."

Also dangerous for Iran in the uncertain period ahead are the airtight compartments separating various forces involved in the crisis.

The shah, increasingly involved in chasing the lengthening shadow of a political settlement, has all but abandoned his once pervasive interest in day-to-day government to Azhari.

The domestic opposition, both lay and religious, is separated by a vacuum from Ayatollah Ruhollah Khomeini, the Paris-based Moslem exile leader determined to remove the Pahlavis from the throne. The opposition here dares not challenge Khomeini for fear of angering the great mass of Iranians who have seized upon the 78-year-old cleric as the symbol opposing all they dislike and want changed.

But the most dangerous vacuum is between the armed forces and the domestic political opposition. They do not know each other, since, for years, the shah has both suppressed the opposition and kept the military out of politics.

Now the shah has failed on both counts and, if he is forced out, they seemed fated to work together.

For now, the top army leadership is still personally attached to the shah and said to reject a regency council or other strategem to continue the family's hold on the throne while removing the unpopular shah from power.

In any case, both the shah and the opposition seem determined to tough it out.

Through Sanjabi, the Political Opposition appears to have slammed the door on the shah's hopes that once Ashura was weathered, a civilian coalition government could be formed allowing him to remain on the throne and lead Iran to fresh elections.

Sanjabi apparently had little choice, given Khomeini's adamant stand. In these circumstances, any civilian government acceptable to the shah probably would founder. Within 24 hours, it would have to lift martial law and restore freedom of the press and assembly. That is tantamount to making Tehran ungovernable today.

So the present impasse suits all the major players inside Iran. The shah seems condemned to soldier on with his floundering military government and at best hope for a gradual lowering of the political temperature.

The domestic opposition shelters behind Khomeini's undiminished powers and seemingly awaits his next push.

The pressures appear intolerable to many Iranians who long for some clearcut solution. But the shah, by one account, seems to be bearing up better than might be expected. "He's depressed, but relaxed," a recent visitor said. CAPTION: Picture, An Iranian army helicopter on patrol flies low over Isfahan yesterday. Until recently, the shah had kept the armed forces insulated from politics. UPI