The menacing battle tanks have left the square outside the mosque, whose gold-covered dome beckons travelers from across the Ochre Desert to this shrine of the Shia sect of Islam.

But riot troops and secret police remain as tangible proof that Qom is the center of a battle between church and state, a conflict which since January has confronted Shah Mohammad Reza Pahlavi with his biggest challenge in 15 years, perhaps even a quarter of a century.

Since the first trouble here in January, every 40 days - corresponding to the Moslem period of mourning - the country has experienced antigovernment demonstrations. By official count, 34 towns and cities have been involved.

So far, each cycle has ended in loss of life - there are believed to be more than 200 dead - and in turn engendered another round of protests 40 days later.

In the process, a basically withdrawn, almost quiescent religious leader has emerged as a symbol of national resistance - almost in spite of himself.

The conflict focuses on the Shia sect's demand for a return to the liberal 1906 constitution and their opposition to land reforms imposed by the shah.

There is nothing of the shah's regal carriage about Shariat Madhari. At 72, he is small and stooped, soft-spoken, given to running his hand through his gray beard, his eyes twinkling from behind black-rimmed glasses.

About 120 miles to the north, the shah lives in Tehran, where the bleak desert gives way to a westernized, car-clogged, polluted capital with all the charm of a Middle Eastern replica of Detroit.

Across the Iraqi border, hundreds of miles to the southwest, lies Najjaf, another shrine of the Shia, who comprise about 90 percent of Iran's population. There, Ayatollah Rouhollas Khomeiny has lived in exile for 15 years, continuing single-minded crusade to overthrow the shah.

But without Qom and Kazem Shariat Madhari, its most prestigious ayatollah - leader in prayer - it is doubtful whether the religious community would have emerged so forcefully as the main opposition to the shah.

On the surface, the government of the conservative shah has only itself to blame for turning equally conservative Shariat Madhari into an opposition activist.

The immediate cause was the government's decision to publish a strong attack against Khomeiny in its controlled press. Khomeiny's prose, in turn, denounces the shah and "his family of looters . . . whose hands are sunk up to the elbow in the blood of innocents" and calls for the army to overthrow the "tyrannical dynasty."

The government's response was itself crude, accusing the Khomeiny of writing erotic verse and of being in the pay of foreigners.

In a town like Qom, those are fighting words. The religious rank and file forced the leaders to react. Protest demonstrations were put down with automatic weapons. The 40-day cycle of death and mourning had begun - as indeed had the rivalry between Shariat Madhari and Khomeiny for leadership of the antigovernment movement.

As a man who has steadfastly proclaimed his anti-shah sentiments, Khomeiny is credited with exercising greater moral authority at the outset, especially among radicals and the young.His rival enjoys the tactical advantage of living inside the country and is thought to have caught up recently.

The timing could not have been better. Iranians high and low carp seemingly endlessly at what has gone wrong, especially since the heady days of the bonanza of quadrupled oil prices engineered by the Shah in 1973.

His failure to pave the streets with gold gave the religious opposition the opening they had sought since the present Shah's father, an army non-commissioned officer, seized power in 1919.

Reza Shah was much influenced by his contemporary, Ataturk, the Turkish reformer. They both tried to modernize and secularize their countries, unveiling women and forcing men to abandon the fez and turban.

The present shah further angered many religious leaders in 1962 by nationalizing and distributing to the made the Shia clergy the country's second biggest landlord.

More intangibly, the shah is paying the price of running a society in transition that is subject to great strains and glaring illegalities.

Caught off balance by the religious backlash, the shah and his government have painted the leadership as retrograde men intent on abolishing land reform, education for girls and forcing all Iranian women into wearing the full-length veil known as the chador.

Shias like to think of themselves as basically representing the creed of the beleagured and oppressed, even though their belief has been the state religion since the 16th century. It took root here because Iran was first threatened by the Arabs, then by the Turkish Ottoman Empire.

Both following the majority Sunni rite of Islam. The Shias differ from the Sunnis in that way they revere Ali, the son of Mohammed, founder of the Moslem faith.

The Shia creed insists on the notion of justice, that man is responsible for his acts - unlike Sunni fatalism - and thus the shah is accountable for his acts.

Moreover, as the shah's government became increasingly autocratic, the mosque came to provide the principal arena for dissent.

Prime Minister Jamshid Amouzegar indirectly acknowledges as much.

"They can say anything they want inside the mosque, curse the Shah and the regime, imperialism, the Americans, demand a government like (Libyan leader Muammar) Qaddafi, but outside they must behave and not break windows and burn down shops" he said in an interview.

In other words, the mosque would seem to be an acceptable safety valve for blowing off steam.

Shariat Madhari's political demands revolve around a return to the 1906 constitution, a document inspired by European liberalism, which would reduce the Shah to a ceremonial sovereign and give veto powers to a five-member committee of mullahs or religious leaders.

The prime minister has accused the religious leaders of violating an unwritten agreement under which the government stayed out of Islamic matters and the religious leaders kept out of politics.

The Shah recently said the 1906 constitution led directly to the partitioning of the country into British and Russian spheres of influence.

Demands for a return to the 1906 constitution are the cement that keeps the religious leadership in vague and ironic alliance with the more sophisticated westernized opposition in the capital.

Although they enjoy mass support, the religious leaders have no detailed program, timetable or organization. The dissidents, on the other hand, have a program but little following.

In private, the politicians lament that the religious community has learned next to nothing about politics since January, and, in the words of one observer, "have about as much political sense as a flock of geese."

The government has not shown great sensitivity in handling the religious community. In early May, troops broke into the compounds of Shariat Madhari and another yatollah here. Two mullahs were killed.

It was a violation of a 13-century-old tradition of sanctuary and a clumsy act of intimidation which the government acknowledged by issuing an apology.

The day the Shah leaves power, seems far off - as indeed does any prospect for a return to what was considered normal before January.

In the process, the religious leadership has registered some modest points against their own fanatics.

Both leaders have felt buoyed enough by the mass movement to come out for a limited version of equality of rights for women, a certain tolerance of the Left and grudging acceptance of land reform.

"The Shah may be right in thinking that the religious movement will blow itself out," an opposition intellectual said. "There may indeed be a limit on martydom, but for the next two or three months the essential question will remain how he handles the religious."