The shah of Iran, overwhelmed by more than a year of mounting opposition to his 37-year rule, flew into exile today with his wife, a few aides and a boxful of Iranian soil after a tearful departure ceremony restricted to a small coterie of top officials.

Piloting an imperial Boeing 707 himself, the shah left behind a country that exploded in joy at his departure, but which faces an uncertain political and economic future, with the likelihood of future chaos and the risk of a violent power struggle.

Officially, Shah Mohammad Reza Pahlavi stuck to the line that he is only going for a winter vacation for rest and medical treatment. But there is little doubt that his "holiday" will stretch into indefinite exile. The blue and white jet carrying him and his party was trailed by an air force cargo plane with packing crates full of imperial belongings.

"I am leaving for Aswan in Egypt and will rest there for a few days," the shah, 59, said in a departure ceremony at the Imperial Pavilion of Tehran's Mehrabad Airport.

"I hope that the government will be able to make up for the past and will be able to lay a foundation for the future.

"The duration of the trip," he said, "depends on my health and I cannot define a time."

The shah left shortly after the man he appointed, Shahpour Bakhtiar, won a confidence vote in the lowerhouse of parliament, formally confirming a new civilian government under a Regency Council that the shah hopes will preserve the monarchy in his absence.

But the architect of his downfall, religious opposition leader Ayatollah Ruhollah Khomeini, issued a "revolutionary order" from his French exile calling for dissolution of the Regency Council and both houses of parliament to pave the way for an Islamic republic under his sponsorship.

He said representatives of the council and parliament should leave the country along with the shah.

The announcement, along with a call for massive demonstrations Friday that many Iranians believe will prepare the way for Khomeini's return, made the viability of the Bakhtiar government even more tenuous.

A key test will be whether workers continue their strikes. The walkouts, which have paralyzed the economy, were a key factor in the year of escalating civil unrest. More than 1,500 persons are estimated to have been kiled in protests against the monarch's autocratic rule during the year.

The violence led the United States to advise the shah this month to leave the country, reversing longstanding U.S. policy of backing his attempt to ride out the revolt.

The shah's departure was carried out in a much more stately manner than his previous flight into exile in August 1953 to avoid arrest by an opposition government.

But a large measure of haste and confusion was still evident as increasing fraternization between martial law troops and demonstrators underscored a marked crumbling of the shah's authority.

The shah originally had scheduled a news conference, but it was abruptly calld off after a busload and several cars crammed with journalists arrived at the airport. After having repeattdly denied that the shah would leave today, palace spokesmen turned back reporters who had been invited to the final press conference, saying the departure had been rescheduled for Wednesday.

Foreign correspondents who arrived later were prevented by soldiers in combat gear from entering the gates in front of the Imperial Pavilion. But a handful of Iranian jouralists were allowed in.

Witnesses said the shah and his wife, Empress Farah, walked under copies of the Koran, the Moslem scriptures, held aloft by security men.

Then, with tears in their eyes, they turned and kissed the holy book before boarding the royal aircraft.

Present at the ceremony, which an official announcement said took place "in an atmosphere of sorrow," were three top generals, a few aides, Prime Minister Bakhtiar and several elderly royal household servants who worked for the shah and his father, Reza Shah.

The shah's father was forced to abdicate in 1941. Like his son today, Reza Shah took with him a boxful of soil from his homeland when at British insistence he departed for exile in South Africa, where he died in 1950 without ever returning home.

Absent at the ceremony today were diplomats of the host countries -- Egypt and probably later the United States -- whose appearance normally is required by protocol. Also missing was the Imam Jomeh, a religious figure usually present at such ceremonits whose duty it is to bless the trip and be the last person to bid the shah farewell.

According to a self-styled palace adviser who informed correspondents last night of the shah's imminent departure, the monarch may go from Egypt to Iraq and Saudi Arabia for religious pilgrimages to the Moslem shrines of Kerbala and Mecca before flying to the United States.

Once in the United States the shah is expected to stay in southern California, where his mother and sister moved last month. The royal family already has bought large and expensive tracts of real estate in the Los Angeles area in apparent preparation for palaces-in-exile.

Preparations for the shahhs departure this time contrasted sharply with the previous exile, when he and his former wife, Soraya, jumped into a small twin-engine Beechcraft airplane at their Caspian Sea retreat of Ramsar and flew to Baghdad in neighboring Iraq to avoid arrest by the opposition National Front government of the late prime minister Mohammed Mossadegh.

When the shah arrived unexpectedly at Baghdad Airport, his plane contained a few suitcases, clothes piled in disarray on the back seat, a case of documents and several of Soraya's small jewelry cases. Two days later, the royal couple flew to Rome, where they were depressed to hear radio reports of demonstrations in Tehran.

Political leaders back home demanded that the Pahlavis be hanged and a republic be declared. Mobs burned portraits of the shah, pulled down royal statutes and desecrated the tomb of Reza Shah, whose body was returned after his death.

According to Soraya's memoirs, the dispirited young shah wanted to settle in America and buy a farm. A day later, however, a CLA-backed coup overthrew Mossadegh and cleared the way for the shah's triumphant return.

"I knew they loved me," he was quoted as saying, referring to the Iranian people. "I wanted to avoid a bloodbath. That's why I left my country temporarily."

On Aug. 21, he and Soraya flew to Baghdad, and the next day took the Beechcraft back to Tehran. Now, 25 years later, some elements of the story remain the same, but others are drastically different.

Thousands of Ianians today joined in a spontaneous, enthusiastic celebration of good riddance to the monarch they have come to hate.

Mobs pulled down his statues and defaced his portraits and the once subservient official news agency, Pars, announced: "The peopel of Tehran raced through city streets in joyous uproar this afternoon after news of the shah's departure spread like wildfire."

In 1953 the same crowd that cheered the shah's departure turned out to welcome him on his return. But today the mood does not seem so fickle. Given the country's polarization and the vehemence of the opposition, Tehran's spontaneous enthusiasm about the shah's departure seems unlikely to be reversed.

The big difference is tha the popular support he enjoyed in 1953 has almost completely eroded and no foreign power seems to be in a position to restore him to power.

Moreover, the opposition to his rule then was political, whereas today it springs mostly from deep popular resentment in a more developed society against decades of authoritarian, often repressive rule following his 1953 humiliation.

Ironically, the government he left behind -- and the one that he hopes will keep his Pahlavi dynasty intact -- is led by a former National Front leader and a protege of Mossadegh.

Before bidding the shah farewell, Bakhtiar told a packed Majlis. the lower house of parliament: "Mossadegh lives."

He pledged to dissolve the dreaded secret police, SAVAK, but added, "I want to clarify that we do need a security police under the framework of the Iranian constitution."

Bakhtiar said religious leaders should be moral guides and stay out of politics. He praised the mostly proshah Majlis deputies as "representative of the country."

Referring to Iran's economic mess and political vacuum, he added, "I credit myself for acdepting the premiership under these moslt difficult circumstances."

Senior diplomats and political observers said the Bakhtiar government's best chances of success lay in hopes that today's massive outburst of unaccustomed joy would relax the situation and encourage strikers to go back to work.

"If the atmophere stays like it is, Bakhtiar may get off the ground," one Western diplomat said.

But he cautioned that extremists are increasingly coming out into the open and that there is a risk of continuing strikes undermining the new government.

"The problem is not the demonstrations; it's the strikes," the diplomat said.

He said that if Bakhitiar fails, even a military government probably could not solve the problem.

"It's too late, and the army knows it," he said. "They can shoot people, but they cannot make them work, even the most bone-headed general must realize this."

Another political analyst agreed: "If Bakhtiar is still in power a week from today, then he has a chance. But he could go very quickly and be swept away by the passion of the moment."

He added, "The dramatic high point was obviously today, but the real political struggle is only beginning."

Khomeini, whom the shah drove into exile in 1963, is expected to be in the forefront of that struggle, whether he returns to his native land on the heels of the shah's depature or remains in the Paris suburb where he has set up his headquarters.

In his latest statement, Khomeini repeated that he would return at "the proper time."

He said the shah's flight to Egypt was the first step toward his goal of overthrowing the Pahlavi dynasty, and that he would soon set up a "provisional government" assigned to form a constituent assembly.

A factor that may restrain the 78-year-old Khomeini, observers here feel, is the palace's indirect threat -- delivered through a spokesman last night -- of an attempt at military repression if the monarchy is abolished.