When Iran's President Ali Khamenei arrived at the United Nations on Tuesday, he was expected to launch a diplomatic offensive to persuade the world community that Iraq was to blame for the seven-year war in the Persian Gulf.

Instead, after U.S. forces in the gulf attacked and captured an Iranian Navy ship loaded with mines, Khamenei found his nation, not Iraq, at the center of embarrassing new questions about military aggression in international sea lanes plied by unarmed merchant vessels.

Why Tehran launched an apparent mine-laying operation at almost the very moment Khamenei was to make his General Assembly plea has left many U.S. Middle East specialists mystified.

Some explain the contradictory and, for Iran, damaging episode as nothing more than a "bureaucratic snafu" by an ill-coordinated revolutionary government. Others saw it as the result of a power play among rival factions jockeying for position in the shadow of leader Ayatollah Ruhollah Khomeini.

The specialists are asking whether the incident shows that Tehran is simply using its stated willingness to discuss a U.N. cease-fire resolution as a way to gain time for yet another offensive against Iraq.

Offsetting this suspicion are reports that after delivering an extremely bellicose U.N. speech, Khamenei returned home Wednesday feeling disappointed and was admitting to some U.S. reporters that the incident had "ruined" his mission.

The gulf episode also left Khamenei, in his maiden appearance as an Iranian statesman, looking foolish as he heatedly denied Iranian involvement despite overwhelming U.S. evidence to the contrary.

"It has undermined his mission and him as a person," said one U.S. official. "He looked very foolish lying in public."

Iran is under the most intense international pressure to cease fighting since the war began seven years ago this month. The U.N. Security Council on July 20 unanimously approved for the first time a resolution demanding a cease-fire and negotiated settlement. The United States is pressing for an arms embargo against Iran for refusing to comply.

The bloody conflict, the longest full-scale war since World War II, has cost both countries about 1 million casualties and tens of billions of dollars in damage. Iraq has long claimed it is ready for peace, but Iran has only recently even hinted willingness to discuss a cease-fire.

U.S. specialists propounding the "bureaucratic snafu" explanation for the timing of Iran's attempt to mine gulf waters say they think that the Iranian military was too busy planning retaliation for the latest Iraqi raids on Iran's oil facilities to consider the possibility that the action, if discovered, would undercut their president's U.N. mission.

"I . . . think this is a case of the left hand not knowing what the right hand was doing," said Gary Sick, the chief Iran expert at the National Security Council during the Carter administration. "The military was seeking ways to retaliate for the Iraqi attacks. My suspicion is nobody was thinking about the timing of Khamenei's trip."

Other experts say the most radical faction within Iran's fragmented leadership deliberately sought to undermine Khamenei's standing at home, halt any move toward ending the war and scotch any moves toward opening dialogue with the United States.

"It could well be there are elements in Iran trying to embarrass Khamenei," said Shaul Bakhash, history professor and Iran specialist at George Mason University. "His four-year term {as president} is about to run out, and new elections are coming."

Bakhash, like some other Iran specialists, said he thinks that an important faction in the Iranian government is ready to end the war but does not know how to do it as long as the ayatollah is steadfastly set against any peace policy.

"Don't look for a logical explanation," Bakhash said. "They are squeezed and isolated and at a loss what to do."

Before Khamenei's U.N. trip, the Iranians had agreed for the first time to discuss a U.N. resolution demanding an end to the war and proposed a de facto cease-fire while an impartial body examined who was responsible for starting the war.

At the same time, the United States had been sounding out Tehran, through third parties, about a possible meeting of U.S. and Iranian representatives during Khamenei's U.N. visit to reduce U.S.-Iranian tensions. But the U.S. attack on the Iranian mine-laying vessel destroyed whatever possibility may have existed for such a meeting.

Lost in the furor was that Khamenei's delegation offered a variation on Iran's original proposal that would turn an informal cease-fire into a formal one once the impartial body reached the "judicial phase" of deciding what punishment to impose on the named aggressor.

The Iranians seem sure that Iraq, whose troops invaded Iran on Sept. 22, 1980, will be found guilty and be held liable for war reparations.

Iraq claims Iran started the war, bombing Iraqi border towns earlier the same month, and has suggested that the two sides submit the dispute to the International Court of Justice.

Sick, like Bakhash, said he believes the Iranians, by accepting to talk about the U.N. cease-fire resolution, have turned a corner in their thinking about the war and are serious about discussing a possible peace settlement.

"There is quite a lot of recognition in the upper reaches {of the Iranian government} that a cease-fire is not such a bad thing," said Sick in an interview. "But the Revolutionary Guard would be very upset at the idea of a stand-down."

The Guard, a militia force parallel to the regular Iranian armed forces, has grown steadily in size and political importance.

Sick views current Iranian politics as a "constant struggle" between "realists" and "radicals" in the leadership over the key issue of whether to sue for peace or continue the war.

But the People's Mojahedin Organization of Iran, an opposition group, strongly disagrees. Its spokesman here, Ali Safavi, charged at a news conference Thursday that Iran's leaders were engaged only in "political maneuvering" at the United Nations.

Their purpose, he said, was to divide the U.N. Security Council's five permanent members over a U.S.-proposed arms embargo on Iran and "buy time" to complete preparations for a major new offensive against Iraq.

Safavi presented new details on the Iranian naval craft intercepted by U.S. forces. The data, which Safavi said was gathered by the group's agents inside Iran, indicated that the vessel was an Iranian Navy vessel staffed by regular officers, whose names he provided.

He said the ship's Iranian Navy name was "Landing Craft Rakhsh" but that it had been reregistered as the "Iran Ajr" with the civilian Islamic Republic Shipping Company as a cover.

He also offered evidence that Tehran had planned since mid-August to mine gulf shipping lanes and had received Khomeini's explicit approval.

Safavi also charged that the Iranian government is producing and stockpiling chemical weapons near the southern war front for use in its next offensive against Iraq, which already has used chemical weapons against earlier Iranian offensives.