ITS GOOD that the Iranian prime minister chose to come to the United Nations to seek a condemnation of the Iraqi invasion. The experience should enable him to learn firsthand of the effects that Iran's own disdain for the international rules, in the matter of the hostages, has had the U.N.'s receptivity in Iran's hour of need. Perhaps it shouldn't be this way: aggression is aggression, regardless of the victim's standing on another issue. But we trust it will be this way, so as to give Iran something to think over.

Given the flow of events -- namely, Iran's travails in the war, the new (parliamentary) stage into which the hostage question had moved in Tehran anyway, and Jimmy Carter's evident eagerness to reclaim the hostages by election time -- rumors of a deal were bound to fly. We know of no evidence that the fix is in. The record of past disappointments argues against it.Implicitly, however, some kind of a deal is conceivable. It depends in the first instance on the Iranians. Whether the prime minister has the authority to negotiate in New York (or Washington) and to deliver the folks back in Tehran, or whether he is simply dabbling in diplomacy for his own political purposes, has to remain a question. By American standards, the imperatives of state should have triumphed over the imperatives of revolution long ago.

But the prospect of a deal depends on Mr. Carter, too. As "obsessed" as he has said he is with freeing the hostages, he must fold in a new factor. Earlier in the fall, the quid that was at the center of hostage debate was some kind of "apology" for past American acts in Iran -- plus restoration of economic ties and a non-intervention guarantee. Now, however, the Iran-Iraq war has given priminence to an additional possible quid, military spare parts or arms, and this adds a prickly international aspect to any prospective deal. For any hostage package that puts Iran in a better position to wage war will have a direct and presumably negative impact on American relations with Iraq and its Arab friends.

Mr. Carter, then, must transit a difficult passage. He cannot turn his back on the hostages or, as Secretary of State Muskie has explained, retain sanctions on Iran simply to avoid an Iraqi charge that the United States is abandoning its stance of "neutrality" in the war. But he cannot, in negotiating for the hostages, carelessly make the United States a military partner of a maverick Islamic regime regarded as a menance by most of the Arab states with which Washington must otherwise get along. The way to split this difference is somehow to tie a solution of the hostage issue to the encouragement of a negotiating process between Iran and Iraq. Mr. Carter needs to be careful, he needs a little room, and he needs help from other nations at the United Nations.