TEHRAN, JUNE 29 -- The Iraqi war prisoners sat down front in gray uniforms. Behind them were several thousand worshippers who had pushed past the Revolutionary Guards and into Tehran University for Friday prayers. On the streets outside the university sat thousands more -- women on one avenue, men on another -- their mats arranged on painted lines directed toward Mecca, their ears attuned to loudspeakers blaring chants and sermons from the Islamic clerics who govern Iran.

The crowds came today not only to practice a weekly religious ritual, but also to hear how Iran's Islamic leaders would explain the worst natural disaster in the country's modern history, the earthquake that killed an estimated 40,000 or more people in northwestern Iran June 21.

Today, Tehran's worshippers heard no less an authority than President Ali Akbar Hashemi Rafsanjani, a religious scholar as well as Iran's preeminent political leader. In a seven-minute sermon, about half of which was devoted to the earthquake, Rafsanjani said neither science nor revolutionary Islam could explain fully what happened in the mountains of northwestern Iran last week.

"Some may ask why God makes us deserving of such disaster after all these years of great holy war," Rafsanjani said. "But it is not like that. The full dimensions of this disaster are unclear to us." The reason for the quake has posed a theological quandary to the religious scholars who hold power in the country's radical Islamic government. The official line in Tehran has been to describe the earthquake as a divine test, but other religious Iranians have called it a punishment from God for deviation from religious conduct. Still others have described it as a natural event basically unrelated to Islam.

Since theology in Iran is also deeply political, the debates over the earthquake's religious meaning have highlighted the sometimes fractious struggle to define the country's Islamic revolution one year after the death of Ayatollah Ruhollah Khomeini, who was perceived by most Iranians as religiously and politically omniscient.

During his sermon today about the earthquake, for example, the reputedly pragmatic Rafsanjani emphasized the need for science and improved government, not mysticism, to meet the test posed by the earthquake. He said Iran should develop seismic technology to detect future quakes and added, "These problems cannot be solved by mere prayers."

Rafsanjani also lashed out at those who have criticized his government's decision to accept large-scale foreign aid in the aftermath of the quake. Rafsanjani called such critics "flies and parasites."

"If we had said we don't want foreign aid, then the world would have said that Iran's government deprived its people and left them alone, and the world would have been right," Rafsanjani said. "No human being, while sitting in an air-conditioned room, can say we do not want aid."

Rafsanjani's sermon was the strongest indication since the earthquake that he intends to capitalize on the event to further distance himself from radicals who oppose his attempts to ease Iran's international isolation. He did not, however, offer any conciliation to the United States today. His only direct reference to the United States was to denounce it for purportedly encouraging anti-Iranian riots in Saudi Arabia three years ago.

Apart from highlighting disagreements about foreign policy and economics that are often couched in religious terms here, this week's theological debate over the earthquake has illuminated another source of tension within Iran's society: the strict enforcement of Islamic rules governing every aspect of personal conduct, from dress to bathroom habits.

A month ago, Iranian authorities in Tehran launched a major crackdown on violators of the Islamic rules governing women's dress. An unknown number of women -- some estimates say more than 1,000 -- were detained or arrested for wearing too much makeup, failing to cover their ankles or allowing their scarves to slip off their heads.

Diplomats reported that a Yugoslav businessman visiting Tehran was pulled from his car and arrested for wearing a tie, a piece of attire seen as insultingly ornate by some of Iran's religious leaders. In addition, notices appeared reminding merchants that it is illegal to display women's underwear in storefront windows.

Iranians said the crackdown reflected a phase in the continuing debate among Iran's clergy over whether to allow a more flexible interpretation of Islam's rules of personal conduct. In the case of the May crackdown, they said, the hard-liners had prevailed.

The chaos caused by the earthquake forced Iran's clergy into debate over their adherence to unbending rules of personal conduct. Students in Qom, Iran's center of religious teaching, presented seven questions to the country's three leading religious scholars, known as grand ayatollahs, concerning special problems posed by the earthquake. The ayatollahs' answers, generally in disagreement, were published widely in Persian-language newspapers.

In response to one question, the grand ayatollahs said it was not necessary to separate the sexes while burying bodies in a mass grave, although one ayatollah said it was preferable to do so.

Another question concerned the Islamic practice of having a member of the dead person's immediate family wash the corpse before burial. The Qom students asked what should be done if no family member was alive or available to do the washing.

Two of the grand ayatollahs offered the sort of flexible response that many urban Iranians hope will become the norm as the fervor of Iran's 1979 revolution recedes and a more stable Islamic society emerges. The two ayatollahs said that in such a case, washing the corpse could be skipped.

The third ayatollah, however, said that washing was imperative. He said it would be offensive for a stranger to gaze on the corpse of another stranger while washing it, particularly if the corpse was a woman and the washer a man. The ayatollah's solution: "Put on gloves, cover your eyes with a blindfold, and have a young child instruct you as you wash."