Formidable as it was, the challenge of overthrowing Shah Mohammad Reza Pahlavi and subduing his powerful army is proving to be just a prelude to enormous obstacles facing the revolutionary forces inspired by Moslem leader Ayatollah Ruhollah Khomeini.

If this were not obvious enough before the provisional government of the new Islamic republic took the reins of power on Sunday, it has been illustrated convincingly since then by the emergence of a revolution within the revolution and an escalation of internecine violence that reached a new high with today's attack on the U.S. Embassy.

Further down the road for Iran are economic problems that some analysts are predicting could lead to monetary collapse, shortages of essential goods and new political convulsions. But the embryonic government seems to be barely even thinking about that crisis until it decides how to come to grips with the immediate internal security threat to Iran.

Had Khomeini been able to finesse a capitulation by former prime minister Shahpour Bakhtiar without a bloody confrontation with the armed forces, his task would be easier and the new government's chances of survival would be better even if still far from certain.

But a handful of Air Force cadets watching a televised rerun of Khomeini's triumphant return from exile altered the odds when their pro-Khomeini exhuberance led to a clash with loyalist troops and 48 fateful hours of clashes that spelled the end of the old regime.

Now, with the instruments of war in the hands of tens of thousands of civilians of widely varying idealogies and with factionalism growing daily within the opposition, Khomeini's seemingly charmed string of revolutionary successes appears to be coming unraveled.

In hindsight, it could be said that it was inevitable given the unlikely alliance of idealogues who rallied behind the flag of Islam to foment the revolution against a common enemy -- the shah.

Socialists, Marxists, liberals and other secular opponents of the shah's iron-fisted rule set aside their differences with religious traditionalists, pragmatists and other elements of the right and pretended that a nation of Islam satisfying all political persuasions could somehow emerge.

The notion that a victory could be followed by civil war -- or even serious competition for power -- was scoffed at by Khomeini's political strategists here and in his exile headquarters near Paris.

"We have a common enemy and a common goal," was the refrain most heard when the suggestion of trouble was made.

Now, having barely savored the fruits of victory, the government of Prime Minister Medhi Bazargan is discovering the flaw in that reasoning. And Khomeini, who called upon his followers to take up arms, is finding out that it is easier to declare a holy war than it is to impose a holy peace.

In an act of desperation amid the postrevolution violence, Khomeini last night went on nationwide television and warned that keeping weapons is haram -- taboo under Islam.

One group, Cherikhaye Fedaye Khalq, People's Sacrifice Guerilla organization, had publicly called upon its followers not to lay down their arms and has urged them to form small guerrilla groups to assure a 'final victory."

The level of paranoia usually rises along with the volume of the day's rumors, often centering on stories about fanatical agents of SAVAK, the hated secret police.

The campus of Tehran University has been converted into a military training base for pro-Islamic Mojaheddin guerrillas and the leftist Fedaye rebels, who say they are determined not to let the hard-won victory slip away. When they are asked what they fear the most, the guerrillas usually answer in one way or another that they are afraid their guns will be taken away.

In the face of daily shootouts by rival factions, Khomeini's aides continue to insist that the problem is exaggerated and that it is natural form of rivalry born out of a wrenching revolution.

However, aside from attempts by some aides to gloss over the problem, concerned members of the government are beginning to look to a reconstitute army as the only hope for disarming the guerrilla groups.

Symptoms of anarchy are everywhere in Tehran these days. Robberies by gun-toting youths wearing the white headband of the revolution are commonplace.

To grasp a possible way out of the breakdown of the social fabric of Iran over the past months, it probably is necessary to understand the Persian psyche, an elusive goal for most Westerners.

But Hossein Amir-Sadeghi, a former aide to the shah and a self-described "extremist monarchist," seemed to touch on the answer in an interview shortly before the fall of the shah's caretaker government last weekend.

Referring to thousands of years of Persian history in which patriarchy has played a prominent role, Amir-Sadegi said, "Scratch a Persian and you will find a dictator. This country needs somebody who is strong."