PARIS -- Iran's missile attack on a reflagged Kuwaiti tanker forces the Reagan administration to define its military commitment in the Persian Gulf with a precision that Washington wanted to avoid. To smoke out the United States, the ayatollahs have chosen the road of escalation and the risk of a bloody nose inflicted by American retaliation.

Why is Iran taking this route now, after reacting in low key to American attacks on Iranian gunboats earlier this month? And why do the ayatollahs figure that American retaliation is an acceptable price to pay for the privilege of shooting up Kuwaiti shipping? The answers are unknowable at this point, but the Iranian actions are plainly neither accidental nor irrational. Both international and domestic political factors make the escalation route logical, and sustainable, for them.

The greatest Iranian frustration has been an inability to play the two "Great Satans" against each other as the Soviet Union and the United States move toward a summit. Since its diplomacy has failed to divide Washington and Moscow, Tehran now appears to be gambling on open military conflict to do that and perhaps bring Iran Soviet support.

In recent months, the Soviets have placated Tehran by making the right noises about joint economic projects during an exchange of visits. But they have not provided any real relief for Iran from the diplomatic campaign for a United Nations arms embargo against Iran and the escalating air war carried out by Iraq's Soviet- and French-supplied warplanes.

Playing for time as it prepares for the renewed land offensive it plans against Iraq, Iran countered the U.S. drive in the Security Council for an arms embargo by giving indications for the first time this summer that it would consider a cease-fire.

The Soviets used this in successfully arguing for a delay in the arms embargo vote. But Moscow was careful to portray its move as part of a continuing cooperative effort with Washington inside the United Nations. The summit track continued to be the important one.

Yesterday's missile attack on one of the 11 Kuwaiti ships that now fly an American flag occurred as Secretary of State George P. Shultz arrived in the Middle East on his way to Moscow for the final summit planning session. Indiscriminate American attacks on Iran now would put Moscow in a squeeze and could even affect the summit. Escalation also brings pressure to bear on the five West European countries that have sent military ships to the gulf area.

For the ayatollahs, would such speculative gains be worth the humiliation and pain that an American retaliation would bring the nation? Because of the culture of martyrdom and the politics of turning persecution into strength that prevail in Iran today, they almost certainly would.

Consider the case of Hojatoleslam Ali Akbar Hashemi Rafsanjani, the speaker of Iran's parliament and the man who arranged for Robert C. McFarlane to fly to Tehran and talk about hostages and arms. That operation blew up in their faces last November.

Six months later Rafsanjani's opening to France met the same fate. Then in July his attempts to work out a modus vivendi with Saudi Arabia collapsed in the Iranian-provoked bloodshed in Mecca.

In any other country, Rafsanjani's political obituary would already be written. But in Iran, the strongest political leader today is none other than this same Rafsanjani, now playing the role of persecuted radical. His rival, Mehdi Hashemi, who leaked the details of the McFarlane visit to a Lebanese magazine in an effort to discredit Rafsanjani, was executed two weeks ago.

Rafsanjani is taking credit for being able to use the American military presence in the gulf to bring 200,000 to 300,000 recruits into the Iranian Army at a time when morale had been sagging. He and his faction might actually welcome American raids as an opportunity to burnish their radical credentials and once again show that the country has to rally around the ayatollahs.

While the situations are completely different, in this one aspect the Iranians resemble another dangerous adversary in America's recent past -- the North Vietnamese, who were also able to transform punishment into unity and whose leaders used the image of themselves as the weak persecuted by the strong to their advantage. The United States has to shape its response to yesterday's missile with such long-term dangers clearly in view.