ON OR ABOUT Jan. 3, 1979, Air Force Gen. Robert E. (Dutch) Huyser, second in command of all U.S. forces in Europe, arrived in Tehran at the express direction of President Carter. By late 1978, it had become clear that Iran was coming apart. A series of general strikes had brought its economic life to a standstill. A military government installed by the shah in November had been unable to restore order. In December, 2 million followers of the exiled Ayatollah Khomeini marched through Tehran's streets crying, "Death to the shah!" Riots broke out in Isfahan, then in Ahwaz, where an American oilman was murdered. On Dec. 24, the U.S. embassy in Tehran was attacked.

It was plain the shah's grip was growing very weak. On Jan. 4 he agreed to take a "vacation" and he appointed Shahpour Bakhtiar to head an interim civilian government. It was at this point that the stocky, heavy-set figure of Dutch Huyser appeared on the scene.

According to press reports at the time, Huyser brought with him the shah's last hope. Huyser's job was to marshall support for Bakhtiar and make sure that the awkward, shaky new government did not fall victim to a military coup. Huyser reportedly accomplished this mission and went home.

On Nov. 4, 1979, the first hints appeared that Huyser's trip may in fact have had a different purpose. Gen. Alexander Haig Jr., the former NATO commander and Huyser's superior officer, claimed in a private talk that Carter had sent Huyser to Iran not to help Bakhtiar but to hasten the shah's fall. The charge was soon echoed by Shah Mohammed Reza Pahlavi himself. In December, in excerpts from a book to be published this month, the shah claimed Huyser had arrived in Iran "with the clear purpose" of neutralizing the Iranian army and thus aiding in his overthrow.

After two days of denials, a high Pentagon official confirmed that the shah's statements "are essentially accurate."

Huyser, now head of the Military Airlift Command at Scott Air Force Base, Ill., has refused to be interviewed. The following account of his mission has been pieced together from U.S. intelligence sources, former officials of the U.S. embassy in Tehran and high-level State Department and National Security Council sources.

The results of there interviews challenge previous accounts of Carter administration support for the shah.

We had been told repeatedly that the president's support for the shah was unwavering; that there had been a massive "intelligence failure" of stupendous proportions because the United States had not been able to interpret correctly the depth of popular discontent in Iran. We were also told that the Carter administration had had no contact with Khomeini or his representatives, and that the rise of the ayatollah had taken U.S. policy makers by surprise.

In the light of new information, none of these assertions would appear to be true. According to high State Department and Pentagon sources, the purpose of Huyser's mission was to "pull the rug out on the shah." These sources say Huyser's marching orders were:

1. To tell the shah that his days were numbered: a new day was dawning in Iran, the U.S. policy of support had changed, and he was "to see it our way" or economic pressure would be applied "until he saw it our way."

2. To tell the shah that he was to leave Iran immediately, since his presence was a continuing source of unrest among the country's top military leaders.

3. To stop any pro-shah military coup and clear the way for Khomeini's return by warning the U.S.-trained generals that if they moved to seize power the United States would cut off all aid.

"By November 1978, our options had narrowed greatly," said a high State Department official who claims that "at a policy level" the return of Khomeini was under constant discussion at that time. There was apparently no other choice. "Any political compromise like Bakhtiar never had a chance," he said. "It was simply too late to save the Pahlavis."

Authoritative State Department sources claim that Khomeini was well known to Carter administration officials as early as March 1977, and that he was already looked on as the main opponent and probable successor to the shah.

"The shah's departure was being discussed as a serious option by early 1977," said a highly placed administration source, who named NSC staffer Robert Hunter as playing a key part. From the summer of 1977 on, military sources claim, U.S. intelligence reports in Tehran were accurately predicting that the shah would not survive. One group of military analysts, headed by Air Force Lt. Col. "Scotty" Wilson, forecast that the shah would fall by March 21, 1978, the Iranian New Year, and that the United States would be expelled from Iran shortly thereafter. "All reports went to Gen. Philippe Gast [head of the U.S. military mission in Iran], from Gast to the embassy's political officer, and from him to Ambassador [William] Sullivan," said one sensitively placed official.

By May 1978, a former diplomat has said, Sullivan was estimating in private conversations that the shah had less than a 50-50 chance of surviving. Other diplomatic officials acknowledge that in the fall of 1978, meetings between Khomeini representatives and such Carter administration go-betweens as former attorney general Ramsey Clark were taking place in Washington, New York and Paris.

In Tehran, meanwhile, the Iranian army commanders, feeling the United States gingerly withdrawing its support and uncertain as to just what American policy was, began to block out plans to save their country through the ruthless use of military force. The planners were men like Lt. Gen. Manourchehr Khosrowdad, head of army aviation and commander of the paratroops, Lt. Gen. Hussein Rabii, the air force commander, and Lt. Gen. Gholam Oveissi, commander of ground forces and martial law administrator of Tehran.

"The view of someone like Khosrowdad was that if you killed only a few demonstrators, you had only made martyrs, but if you killed 100,000, it still left you with 35 million plus you had made an object lesson," said one insider. The shah's generals, he added, were ready to administer that lesson.

Throughout the latter part of 1978, the generals waited for word from their king to move. It never came. "What nobody counted on was the total collapse of the shah," said a State Department official. "By November, Sullivan was saying in conversations that the shah was quite incapable of making a decision." A diplomat formerly in Tehran said the generals "had expected a monarch . . . aInstead, they got this boyish, fatalistic, morally paralyzed man."

According to these men, as the shah became more confused and as his depression grew more deep, he became more willing to compromise. On or about Dec. 12, in the presence of U.S. officials and making bittersweet jokes, the shah signed a compromise plan that had been arranged by two of Khomeini's key aides. Under its terms, the shah had to leave Iran immediately but a four-man regency council headed by the old National Front leader Dr. Kerim Sanjabi would rule in his place. Free elections would be held in three months; until then, the Pahlavi dynasty would be preserved.

One of the compromise's authors was Hassan Nazih, who would become head of the National Iranian Oil Co. in the new Khomeini government. The other was Ayatollah Sayed Beheshti, whose house had been the apex of the secret Khomeini apparatus in Iran throughout the revolution, the distribution point for the flood of Khomeini speeches on printed sheets or recorded in Farsi on cassettes from Paris, speeches that called for the Pahlavi regime to be cast into "the garbage can of history."

But in Washington by then there was no unanimity of policy. Many segments of the administration were maneuvering at cross-purposes. For example, the Iran Working Group at the State Department was behind the proposal, while key NSC staffers and other high State officials were opposed. "I believe it would have failed," said one. "By that time, anything that would have kept the shah on the throne had no chance of success."

Others believed the shah signed because he'd been "playing for time." He was trying to appease U.S. policy makers," one analyst said, "or what he thought was U.S. policy."

One thing was clear. The shah's willingness to leave his country gave his generals a bad scare. They grew ugly. One cold, bright December morning, a delegation of all the heads of Iran's armed services appeared at the shah's Niavarin Palace. "They told him that if he left the country, they'd tear the place to pieces," said a State Department official. In an interview last April with a high-level U.S. official, Gen. Gholam Reza Azhari, the shah's former chief of staff who became prime minister of the military government Nov. 6, told of having stopped the shah from leaving so many times that once the monarch had come to him and asked, almost pitifully, "Am I under arrest?"

By late December, the shah's generals were planning action. According to intelligence sources, three separate coups were being planned. The most alarming one was being brewed by the air force. On a Wednesday in laate December, Pentagon officials received an urgent intelligence report from Tehran warning that a group of Iranian air force officers backed by Gen. Rabii were going to bomb the holy cities of Qom and Meshed and then fly to Saudi Arabia. "A coup will take place this Saturday," the cable said.

"It was a bona fide threat," said a military official. The report had an A3 rating, meaning it was believed to be highly accurate.

Huyser flew to Tehran on Jan. 2 or 3. He stayed with Gen. Gast, the head of the U.S. military mission. Both men were often out of uniform and wore bulletproof flak vests under their suits, sources say. Gast was assigned the usual complement of submachinegun-toting Iranian guards; Huyser had brought four bodyguards from the Air Force Office of Security Investigations. When the two generals went anywhere, they rode in a sealed, bulletproof car, with bodyguards in a lead car and two heavily armed chase cars following.

The shah's army had been the keystone of his power, and his passion for it had been his most sensitive personal quirk. His taste for military pomp and buying of advanced weapons had amounted to almost a mania. In 1977, Iran's army was the largest in the Persian Gulf region, numbering more than 300,000, plus 81,000 in the air force and 18,500 in the navy. It had the U.S.-made 14 Tomcat fighters, among the most advanced in the world, equipped with high-technology Phoenix missiles, also U.S.-made. Largely American-armed, its officers mainly U.S.-trained, it had suddenly become the target of U.S. foreign policy.

For 10 solid days, before 10 every morning, double-rotor helicopters, Bell US1Hs and 214s, would appear out of the sky and then settle heavily on the helicopter pad of the parade ground northwest of the Supreme Commander's Staff Building in Tehran, nerve center of the imperail Iranian armed forces. Iranian generals, clutching their braided caps, would get out of the grounded machines and go in. Up on the second floor, inside the chief of staff's briefing room, they would reassemble before the craggy-faced Dutch Huyser.

What Huyser faced was an Iranian command that had split into hawk and dove factions. The doves had already formed a delegation to go to Paris and approach Khomeini in an attempt to avoid a collision. Huyser scotched this, sources said.

The hawks had clustered around two figures. One was Gen. Rabii, who had involved himself in a second propopsed coup. But the most important faction centered on Gen. Khosrowdad, whose coup, sources say, "would have been the biggest and most violent." Iran's ambassador to Washington, Ardeshir Zahedi, who was in Tehran at the time, was to have handled the coup's "civilian aspects," sources say. Khosrowdad already was openly bragging of the coup's likely success.

"Huyser really worked on them," said a U.S. military source. "He really did a number on them."

One Iranian general said, "I saw Khosrowdad's face as he came out of one of the briefings. He looked like a private."

Khomeini by then was announcing his plans to return to Iran to install an Islamic government that he would personally control. Highly placed sources said Huyser made clear to the shah's generals that there could be no interference with Khomeini's plans. "He talked in the briefings of what would happen when Khomeini returned, of all the options available," said an intelligence source. "He was very clear as to what Iran's commanders could or could not do."

The shah and Huyser met only once, when Huyser was accompanied by Ambassador Sullivan. "The one thing that was on the minds of both of them," the shah has written in his forthcoming book, "was to know on what day and at what time I would be leaving."

The shah left Iran for good on Jan. 16.

Yet U.S. policy makers still feared that, exasparated by their defeats, Iran's generals would turn savagely on the people. As late as Jan. 30, some diehard commanders threatened they would arrest anyone who was named to the provisional government Khomeini had set up under Mehdi Bazargan.

Huyser had only planned to be in Iran for a short time. The visit stretched to two weeks, then a month. "It took time to get the fire to go down," said an intelligence source.

On Feb. 5 Huyser left Iran. "By that time his actions had destroyed Iran's armed forces," said a bitter military officer who was there. "The mullahs had been among the army and it had disintegrated."

On Feb. 10, after two days of fighting, the troops withdrew to their barracks and Bakhtiar's government collapsed. Among the first to be executed by Khomeini's Revolutionary Council was Gen. Khosrowdad. Gen. Rabii, who had said that Huyser "picked up the shah as if he were a dead mouse and threw him out of Iran," was sprayed with machinegun fire in April. More followed, until, by U.S. estimates, "30 percent of their top military commanders were killed."

Said a former U.S. ambassador, "It was a slaughter."

But it might have been even worse, some American officials argue: a bloody civil war, with substantially the same outcome. "A nation has a right to decide its own destiny in any way the majority sees fit," says one State Department official. "Khomeini was the coming power in Iran. We tried to prevent a massacre."