The ailing deposed shah of Iran, appearing emaciated and drawn after an all-night flight, checked into Cairo's best hospital under heavy guard today at the beginning of what President Anwar Sadat said will be "permanent" asylum in Egypt.

His sudden departure from Panama, where he had resided since Dec. 15, threw an unpredictable new element of confusion into efforts to gain the release of American hostages being held in the occupied U.S. Embassy in Tehran.

It also exposed Sadat to a new round of criticism from Arab opponents who support Iran's Islamic revolution and raised the spector of increased resentment among Egypt's own Moslem fundamentalists.

U.S. Ambassador Alfred Atherton contacted Egyptian government officials before the arrival of the ousted shah, Mohammad Reza Pahlavi, to express American concern and urge that it be presented publicly in a way that would soften any resentment in Tehran or the Arab world, informed officials said.

Sadat defiantly underscored his willingness to accept the fallen monarch, driving to the Cairo airport to welcome Phalavi personally and accompanying him in a helicopter to the 300-bed Military Hospital in the southern Cairo suburb of Maadi.

Sadat's opponents at home have voiced opposition to receiving the shah. Khalid Mohiddin, leader of the leftist Progressive Unionist Rally, renewed the criticism today by saying: "Egypt doesn't need any more problems than those it already has."

Similar reluctance to grant asylum to Pahlavi has come from the Socialist Labor Party, a tolerated opposition group with about 30 seats in the 392-seat parliament. Mohiddin's party has no seats in the assembly.

Egyptian analysts said the two leftist parties had too small a following to raise serious problems over the former shah.

They pointed instead to rightist groups such as the Moslem Brotherhood as the source of possible trouble. These groups, some of which operate underground, have opposed Pahlavi's presence here out of support for the Islamic revolution that pushed him from the throne in Iran.

The deposed shah, along with former empress Farah and half dozen aides, occupied rooms 201-215 on the third floor of a wing overlooking the sunlit Nile river. He wore a trim three-piece pinstripe suit and sunglasses as he entered, but was unable to conceal his ashen complexion and weight loss so severe that the tendons of his neck stood out clearly.

[Among the shah's aides is Robert Armao, an associate of U.S. banker David Rockefeller. Armao, who has served as the shah's spokesman, flew to Egypt to be with the dethroned royal family, his office in New York said.]

The 60-year-old Pahlavi's voice was frail as he warded off reporter's questions, saying: "We will have ample time to talk after the operation."

As Pahlavi and his wife entered the elevator to go to their suite, Sadat's wife Jehan and her two daughters Noha and Jehan embraced Farah in a display of concern.

Sadat has assigned a 15-man team of Egypt's best doctors to look after Pahlavi. They immediately began tests for possible surgery to remove his spleen, believed affected by cancer.

Dr. Salah Shanbandar, head of the Egyptian Cancer Institute, said spleenectomies are relatively routine at the hospital, which enjoys a high reputation by Egyptian standards, but that Pahlavi's weakened condition made any surgery dangerous.

Dr. Fouad Nur, a military physician on the shah's Egyptian team, cast doubt on the posibility of Pahlavi's American doctors coming to perform the operation as had been planned before he left Panama. Whatever is done will be handled by Egyptian surgeons, Nur told the official Middle East News Agency.

His insistence on Egyptian doctors reflected Sadats own determination to offer Pahlavi an Egyptian home whatever the consequences. Observers here noted that, given Sadat's attitude, Pahlavi has found a refuge he can count on as permanent for the first time since he left Iran Jan. 16, 1979.

Foreign Ministry officials declined to say whether Egypt has an extradition treaty with Iran. It was one day before extradition proceedings were to begin against him in Panama that Pahlavi left his tropical island retreat there. In any case, Sadat has made it clear he has no intention of forcing him to leave regardless of any treaties.

Iran and Egypt broke diplomatic relations last year after the revolution.

Sadat has cited Islamic principles of charity and hospitality in explaining his firm support of the deposed shah.

Egypt was the deposed monarch's first stop after he left Iran, and he received repeated invitations to take up permanent residence here as he moved successively to Morocco, the Bahamas, Mexico, New York and Panama.

Sadat is said by his aides to feel a strong sense of personal gratitude to Pahlavi, who granted Egypt $1 billion in aid after the 1973 war and donated an estimated 48 million barrels of oil to avert a severe shortage here in 1974. a

In addition, some sources suggested that Sadat's feeling on the matter are strengthened by his own growing military and strategic alliance with the United States, which in some ways makes him the former shah's successor in the Middle East as a defender of Western interest. It is in that context, they added, that Sadat has openly criticized the way Pahlavi's friends -- implicitly including the United States -- have responded to his travail since he lost the Peacock Throne.

Sadat's gesture also is seen here as raising his stock with Washington only two weeks before he is to visit President Carter for crucial talks on the stalled negotiations with Israel over Palestinian autonomy in Gaza and the West Bank.

In accepting Pahlavi, Sadat has relieved the United States of what might have become an additional obstacle to freeing the Tehran embassy hostages if the deposed monarch had returned for more treatment on U.S. soil. Islamic students occupied the embassy Nov. 4 after Pahlavi was admitted to a New York hospital for treatment of lympahtic cancer and removal of his gall bladder.

In the Middle East, Sadat's move was likely to harden the opposition of Arab nations contesting his peacemaking with Israel. Although many Arab leaders oppose the exceses of Ayatollah Ruhollah Khomeini's Islamic revolution, most had little respect for the shah's agressively pro-Western policies and his pretensions to regional leadership in the Persian Gulf.

Domestic criticism in Egypt has been blunted, however, by Sadat's insistance that his offer stems from Islamic compassion. It is in the same lenient line, he told parliament in a speech several months ago, as Egypt's previous attitude toward its own former royal family and King Idris of neighboring Libya.

Idris, overthrown by Col. Muammar Qaddafi in 1969, recently celebrated his 90th birthday in the Cairo suburb of Heliopolis, where he lives in comfortable asylum out of the public eye.

The officers who led Egypt's 1952 revolution expelled King Farouk on his royal yacht but were careful to guard him against harm.Since then, members of his family have been allowed to return here on visits.