The government of President Anwar Sadat today appeared to be preparing to welcome the deposed shah of Iran, who left Panama amid wrangling over a spleen operation and an Iranian extradition request.

Although government officials would not immediately confirm any plans to receive the shah, there were signs that such preparations were under way.

The gesture by Sadat, who gave the shah his first haven when he left Iran in January 1979, seemed likely to further irritate Egypt's relations with other Arab countries, already outraged by his peace treaty with Isreal. In addition, providing asylum for the exiled monarch could provide a rallying point for Egypt's ineffectual but noisy internal oppositon.

A standing offer of asylum by Sadat heretofore was not accepted for a variety of reasons, including doubts about whether the ex-monarch could get proper medical care in Egypt for his cancer and other ailments.

Egypts boasts a cancer institute in Cairo and the modern Military Hospital in the Cairo suburb of Maadeh, where a special wing reportedly was being readied for the shah's arrival. Nevertheless, the general level of Egyptian medicine is low, and Egyptian officials who need care generally go abroad. The defense minister, Gen. Kamal Hassan Ali, recently was in suburban Washington for what was described as a series of checkups.

In addition, the United States previously had been reluctant to see the shah take up residence in Egypt and possibly further complicate Sadat's international and domestic probelms in pursuing the Camp David accords.

The offer of asylum to the shah further defines Sadat's pro-Western orientation and his readiness to brave the current of Islamic fundamentalism that has spread from Iran to much of the Middle East, to some extent even to the streets of Cairo.

Sadat has cited Islam's own tenets in defending his repeated offers to the shah to take up permanent residence in Egypt. It is an act of Moslem compassion, he told parliamentary critics who questioned the wisdom of allowing the shah into Egypt.

But Sadat's hospitality also is the reward for past favors accorded by the shah to a struggling Egyptian economy. Iran donated about $1 billion to the strained Sadat government after the 1973 Middle East war and the following year helped avert an oil crisis by shiping to Egypt about 48 million barrels of crude.

It seemed natural then for the shah to stop first in Egypt after being driven from his throne. The Iranian monarch in what he then described as a "vacation," spent about two weeks at the upper Egyptian resort of Aswan, staying at the elegant Oberoi Hotel on Elephantine Island.

From there he moved to Morocco, where King Hassan II at first welcomed him, but gradually began dropping hints that he should move on. After his stay in Marakkesh, the shah moved on to the Bahamas before renting a villa in Mexico. In October he moved to New York for treatment of cancer and bile duct ailments.

His stay prompted the seizure of American hostages in Tehran Nov. 4.

By that time, he had bec ome a diplomatic liability, and Mexico would no longer have him back. The rest of the world shunned him as well. Only after U.S. appeals did Panama accept him.

Throughout, however, Sadat stood firm on his offer of asylum, occasionally renewing it publicly and accusing the rest of the world of callous treatment of the deposed monarch. To underline his gesture, Sadat had his ruling National Democratic Party pass a resolution in the Egyptian People's Assembly, or parliament, formally offering the shah a place to live.

Egypt has a variety of palaces to house the former monarch in relative comfort. The government maintains several former royal residences in Cairo, such as Kubbeh and Tahera palaces, and the Safa Palace in the Mediterranean city of Alexandria. Sadat also has residences at Aswan.

The Egyptian government was exceptionally secretive about the shah's travel plans tonight. However, Egyptian photographers and television cameramen were told to report early Monday to the presidential palace in Cairo for "something important."

The government secrecy appeared to reflect a desire to maintain the best possible security for the shah. In what may have been a related development, security precautions at Cairo Airport were especially heavy today, with soldiers carrying AK 47 assault rifles with fixed bayonets standing guard as passengers alighted from airplanes and picked up their baggage inside the terminal.

Egypt's security forces, although ponderous and at times confused, are considered by Western experts to be capable of protecting the shah efficiently.

Observers said demonstrations were unlikely in any case, even by Egyptians for whom the shah's presence would be undesirable. Two leftist groups -- the Progressive Unionist Rally and the Socialist Labor Party -- have officially criticized Sadat's willingness to harbor the shah, as has the rightist Moslem Brotherhood. But none of these groups has stirred any popular show or resentment of the repeated offers of asylum.