President Anwar Sadat, defying the new rulers of Iran on their own theological grounds, today offered political asylum to the homeless shah "in the name of the Egypt of Islam."

Sadat's gesture reinforced similar offers made soon after the Iranian monarch was driven from Tehran early this year and took a brief "vacation" in upper Egypt. It was part of a two-hour speech before Egypt's new parliament during which Sadat challenged his critics - among them Iran - to either improve on his peacemaking with Israel or stop complaining about it.

His offer to the shah, in the name of Islamic principles, was seen as an attempt to embarrass Ayatollah Ruhollah Khomeini and his Islamic followers in Iran who have broken relations with Egypt and reviled Sadat in the name of Moslem solidarity with the Palestinians and their Arab supporters.

There was no indication whether Sadat's offer foreshadowed an actual decision by Shah Mohammad Reza Pahlavi and his family to leave their retreat in Mexico and take up residence here. It was noted, however, that former secretary of state Henry Kissinger, who helped arrange the shah's entry into Mexico, is scheduled to see Sadat next Thursday during a two-day visit to Egypt.

Sadat opened his reference to the shah by expressing pity for him - the man, he said, who was courted by many when he ruled a wealthy country and now is turned away in his search for a safe haven. Although Sadat did not mention the United States, his allusion to U.S. policy seemed clear.

"This man stood by us," Sadat said of the shah, then added: "In the name of the Egypt of Islam, in the name of the Egypt of civilization, in the name of the Egypt of ethics, I say we would welcome the shah and his family in political asylum."

Sadat presented his offer as part of an Egyptian tradition of tolerance, a tradition, he said, that included the family of King Faruk whom Sadat helped depose in the 1952 Egyptian Revoluation headed by the late Gamal Abdel Nasser. In that spirit, he said, some members of the Egyptian royal family have returned to visit and others have been allowed to be buried in Egyptian soil. Although Sadat did not say so, Idris, the deposed Libyan monarch, also resides in Egypt.

One member of parliament stood up and shouted what appeared to be an attack on Sadat for his offer, but was quickly urged back to his seat by another legislator. In general, however, the People's Assembly membership sat impassively through Sadat's comments on the shah and cheered loudly at several points concerning Egyptian peace moves.

Their enthusiasm for Sadat's policies reflected what observers here generally agree is broad popular support for the peace treaty with Israel. Sadat's new National Democratic Party won more than 320 seats in the 392-seat assembly in elections earlier this month billed as Egypt's first multiparty vote since the revolution.

In reviewing these policies, Sadat taunted his Arab critics by comparing himself to the Biblical Noah trying to convince the people to pay heed to his warnings. The people disregarded Noah and the deluge followed, Sadat said to a burst of applause.

"I would quote the Prophet Mohammed," Sadat said of his Arab leaders who disregard his own warnings, "God have mercy on them."

Running throughout Sadat's remarks on his Arab opponents was the challenge that, if they can, they should do better and liberate more Arab land than he has through their own policies. He strongly suggested they would be unable to do so, however, and labeled them with his now-familiar insult: "dwarfs."

Sadat, seeming to slip away from his prepared text and leaning forward on the polished-wood lectern, took a particularly sharp jab at President Hafez Assad of Syria, a major leader of the Arab camp opposing Egypt's peacemaking. On several occasions, he referred to Syria's Baath Party leadership as the "Allawite Baathists." This underlined sectarian tensions in Syria, where Assad's followers from the Allawite minority rule the country's Sunni Moslem majority.

Anti-Allawite feelings may have played a role in the slaughter of at least 50 military cadets recently at an academy in Aleppo.

But the general tone of Sadat's remarks seemed softer than in the past. In particular, there was no reference to Saudi Arabia, Egypt's longtime benefactor that came under caustic criticism from Sadat after the kingdom joined the Arab financial, diplomatic and political boycott of Egypt designed to reverse Sadat's peace policy with Israel.