Fallen Shah Mohammad Reza Pahlavi was entombed in a Cairo mosque today after an Islamic funeral with full military honors that sought to surround him for a final moment with the pomp and splendor he once enjoyed as Iran's "king of kings."

However, most of the world's nations shunned the event.

President Anwar Sadat, stiff in a blue field marshal's uniform and knee-high jackboots, saluted solemnly as a row of trumpets blared a funeral march. A long cannon boomed 21 times to signal Egypt's official mourning for the man-widely despised in his own country -- whom Sadat called "my true and dear friend."

Sadat was flanked by former U.S. president Ricahrd Nixon and Crown Prince Reza. Nixon and deposed King Constantine of Greece were the only foreign dignitaries of note to join Sadat in bestowing final honors on the Iranian monarch, who was chased from his Peacock Throne 18 months ago.

Sadat was the only serving head of state in attendance.

President Carter, weighing past friendship with the shah against concern for U.S. hostages in Tehran, delegated U.S. Ambassador Alfred Atherton to represent the United States. The leaders of Britain, France, China, Israel and Australia similiarly named diplomats here to attend the funeral. Other Western nations apparently feared that even this demonstration of official respect for the former shah could complicate difficult relations with Iran's new Islamic leaders and the country's oil supplies.

Among the Moslem countries, many of which have delicate problems at home flowing from Ayatollah Ruhollah Khomeini's Moslem fundamentalist revival in Iran, only King Hassan II of Morocco sent a representative.

Defying these timidities, Sadat ordered a full state funeral for Pahlavi in what he called a demonstration of the Islamic virtues of friendship and hospitality. Similarly, he had welcomed the shah and his family last March, despite protests from Moslem leaders here and abroad, and provided him with the best medical care Egypt had to offer until his death Sunday morning from complications arising from a six-year bout with lymphatic cancer.

The shah, 60 years old when he died, was put in marble-walled tomb by six white-gloved Egyptian sailors in the 19th-century Rifai Mosque under the shadow of Cairo's Citadel, a hillside fortress built by Saladin after his victory over the crusaders. It was the same spot where the shah's father, Shah Reza, was buried temporarily during World War II before being repatriated to Iran.

An Iraqi, Shilite Moslem clergyman officiated at the funeral rites as male members of the shah's family looked on. In keeping with Moslem tradition, the shah's widow, Empress Farah, and other female members of the family kept their distance until the last moment, when they were allowed to enter the tomb briefly.

Leading them was Farah, statuesque, unbowed and apparently dryeyed, and Princess Ashraf, the shah's twin sister who was regarded during his lifetime as one of his strongest and most influential supporters. One woman in the party, wearing a black dress and black veil like the others, broke down in uncontrolled sobs and had to be led from the mosque.

As the trumpets' blare faded away and Sadat dropped his saluting hand from his visor, three more cannon rounds sounded, signaling that the burial was complete and the tomb sealed. Nixon, appearing slumped and tired after the mile-long funeral procession in near 100-degree heat, turned and hugged Prince Reza, shook Sadat's hand and walked carefully down the mosque stairs over a gold-edged, red carpet 75 minutes after the funeral began.

The young Reza, 19, smiled faintly and exchanged embraces with Sadat and Constantine before receiving condolences from the handful of diplomats. He then entered a black limousine and sped away to Kubbeh Palace, the official guest residence made available by Sadat. Sadat, his face strained from the effects of the hot march during the Moslems' Ramadam fast, also entered his limousine and drove off, followed by Farrah and her other three children.

The Egyptian president had led several thousand mourners, including members of the Egyptian government, in the solemn funeral procession accompanying the shah's coffin to the mosque through a crowded low-rent Cairo neighborhood.

The coffin, draped with the green, white and red imperial Iranian flag, rested on a black caisson pulled by six shining black Arabian stallion. Officers from the Egyptian armed forces and Sadat's presidential guard walked at each corner, and others followed carrying the shah's medals on gold-braided, black velvet cushions.

Ahead marched Egypt's presidential guard band, playing the Imperial Iranian Anthem, and a selection of more than 1,000 officers in full-dress uniform.

Sadat, flanked by Constantine on his left and Nixon on his right, walked slowly and solemnly directly behind the caisson. Sadat's wife, Jihan, and the shah's widow walked on either side of the chief mourners, joined by Crown Prince Reza as the procession moved out after preliminary prayers at the Abdeen presidential headquarters.

"Loyal Egypt bids farewell to the shah," said a sign strung over their heads across the street.

Tens of thousands of Egyptians, a small crowd by Cairo's standards, waited along the street to watch the procession pass by. Many thousands more watched the ceremony live on government television, crowding stores displaying sets.

At some points during the half-hour march, spectators shouted "God is great" and "there is no God but Allah." But aside from some shoving to get near the barricades, the crowds were emotionless and even calm.

Plainclothes and uniformed police mounted a tight security net around the procession route, keeping spectators out of buildings overlooking the street and using electric cattle prods to push back pressing reporters and photographers.

Aziz Sulaiman, an engineer at the government's Nuclear Energy Authority, said he and about 1,000 others from his office building had been given the day off and received free bus transportation to the procession site as an inducement to attend.

Asked why, he replied: "Because the shah helped us during the war. He sent us aid."

Sadat, who also has frequently mentioned the shah's dispatch of Iranian oil to help a desperate Egypt during the 1973 war with Israel, has offered to care for the shah's wife and four children permanently. To signal his protection, he returned with them to Kubbeh Palace today's ceremonies.

Spokesmen for the imperial family said, however, that nothing has been decided yet on a permanent residence. After five months of virtual isolation behind the walls of Kubbeh Palace, the empress is said to be restless. But outside the walls, it is feared she could become a target of Islamic zealots of the new Iran.