Iran announced today that it had recaptured its port of Khuninshahr on the strategic Shatt-al-Arab waterway, killed the commander of the Iraqi garrison there and forced the surrender of 30,000 Iraqi troops holding the city.

The Iranian announcement, if true, would mean Iraqi troops have lost their last big foothold inside Iran. It appeared likely to increase fears among Arab leaders in the Persian Gulf region that Ayatollah Ruhollah Khomeini's Shiite Islamic revolution could threaten their own Sunni Moslem rule with a victory over President Saddam Hussein's Iraqi forces.

There was no immediate independent confirmation here that Iran has retaken Khuninshahr, formerly known as Khorramshahr. However, an Iraqi war communique issued tonight said its forces were engaged in large battles with Iranians inside the port city, inflicting heavy casualties on them and in some cases driving them back. It did not specifically contest the Iranian claim, which was given further credence by an Iranian invitation for foreign journalists to visit the city.

The Iranian claim came amid indications from Iraq that it was seeking additional aid in the 20-month-old Persian Gulf war from other Arab states, including Egypt.

If Iran's claim is true, it would mark the most important victory to date in its long struggle to oust Iraqi troops from its territory and its recapture of the last major Iraqi-held town. In effect, the war may be coming to an end on its own after long, fruitless months of attempted mediation by various outside parties.

Iranian recapture of Khuninshahr, Iran's second-largest port on the eastern shore of the Shatt-al-Arab, would add momentum to a series of Iranian offensives that have returned to Tehran's control more than one-fifth of the 7,700 square miles Iraq captured when the war broke out in September 1980.

The reported Iranian victory would also mean that there has been a spectacular collapse of the Iraqi Army, an event that could hold extremely serious consequences for Saddam Hussein's political future.

The battle for Khuninshahr, renamed early in the war by the Iranians as "the city of blood" because of the fierce fighting there, began only two days ago and was expected to be long and bloody because of the large number of Iraqi troops there.

On Saturday, however, the Iranians said they had pushed all the way to the Shatt-al-Arab west of the city, cutting off Iraqi supply lines and escape routes back into Iraq. This apparently unnerved the Iraqi Army and led to its rapid collapse today after only two days of battle.

It was not clear from the Iranian communique whether all Iraqi troops actually had surrendered or whether there was still some fighting. In announcing the victory, it said Iranian troops controlled all key buildings, including the railroad station, customs house and main mosque.

This seemed to indicate that there might still be some pockets of Iraqi resistance inside the war-shattered city, which lies only about eight miles down the waterway from Iraq's main port of Basra.

Earlier reports yesterday estimated that 40,000 Iraqi troops were committed to the defense of Khuninshahr, many of whom had retreated from positions farther north and east in the last two months of hard, intermittent fighting.

The reported collapse of the Iraqi defense of the city came as Saddam Hussein made another stirring appeal to other Arab states to send troops to help him hold off the advancing Iranians and to accept Egypt back into the Arab fold, presumably to smooth the way for increased Egyptian military assistance.

In an interview published here today with two Kuwaiti newspapers, the Arab Times and Al Siyassah, Saddam said he would "open all doors" if the Egyptian Army came to Baghdad and also called upon the Arab nations to "welcome Egypt back to their fold."

"For every single step President Hosni Mubarak takes toward the Arabs, we shall take two steps, and true Arabs should do likewise," he said in his most explicit bid to date for Egyptian aid and for Egypt's reconciliation with the Arab world.

Saddam Hussein did not say, however, that Iraq was ready to restore diplomatic ties with Cairo, severed in March 1979 after Egypt signed the peace treaty with Israel.

United Press International reported from Beirut that an Iraqi spokesman said Monday that Baghdad "would consider any future offer by any Arab state to send either regular or irregular troops to oppose the Iranian enemy."

Saddam Hussein, like most of the leaders of the Arab states around the Persian Gulf, regards Egypt now as the only serious military and political counterweight to Iran left in the Arab world. As his war difficulties have grown, he has been promoting a reconciliation with Cairo in hopes of gaining outright Egyptian support for his struggle with Iran.

Egypt has been selling an increasing amount of war materiel to Iraq, but its leaders repeatedly have indicated that they are not prepared to send regular Army units to Iraq.

There are about 30,000 Egyptian recruits and volunteers serving with the Iraqi Army in various capacities as well as several thousand Jordanian volunteers and thousands of other Arab ones drawn from among those living and working in Iraq.

Nevertheless, Western and Egyptian analysts of the war believe that troop strength has not been the main reason for Iraq's serious reverses on the battlefield since mid-March. Instead, they cite a lack of leadership and poor morale among the Army's rank and file.

The implications of a defeat at Khuninshahr for Saddam Hussein are uncertain. Assuming that he had scored a certain victory early on in the war, the Iraqi leader personalized the struggle, calling it "Saddam's Qadissiya" after a 7th century Arab victory over the Persians at a battle near Baghdad.

Having so closely identified himself with the war, Saddam Hussein must now find a way to extricate himself from it and explain away the string of defeats at the hands of what had been widely regarded at the beginning as a country and armed forces in revolutionary turmoil and incapable of fighting.

He nonetheless is believed here to still have a large measure of control over the ruling Baath Party and the security apparatus, although his standing with the Army at this point is less certain