Events have smoked out the ayatollah. Methods and motives once shrouded in a fog of religiosity have emerged in the clear light of day and acquired a kind of logic. What once looked like a weird chess match with a supernatural being turns into a not wholly unfamiliar bargaining game.

At the outset it was believed by many, including most of those managing the crisis for the administration, that the ayatollah was merely the captain of a ship driven by the blind, elemental forces of a revolutionary tempest. Now we know better. Hostages are bound and set loose when the ayatollah gives the word. When he doesn't give the word, a government falls. When he talks of spy trials, the student demonstrators quickly take up the cry. He is the master of events, not the victim.

The direction of his leadership is equally clear. The ayatollah courts confrontation with the United States. It is notable that there were no protests against the diplomatic establishments of Morocoo and Mexico when those countries offered haven to the deposed shah. The storm broke only when the ailing monarch entered a hospital in New York.

When it comes to the shah, moreover, the ayatollah puts aside the pretense of being an imam, or holy martyr, and descends into the marketplace. Even as he announced that he would put some American hostages on trial for espionage, he made it clear that the trials would be scotched if the United States returned the shah. In suggesting the trade, he used a phrase from the bazaar -- tahkfeef , meaning discount. In other words, he would make a discount on the trial of the Americans in exchange for the shah.

Just why the ayatollah acts this way is not much in doubt. The central fact is that his Islamic movement is proving itself unable to govern. It cannot deliver basic supplies at reasonable prices or provide regular services, including law and order. Disaffection has been mounting among secular elements in Tehran and on the part of the submerged minorities all around the edges of what used to be the shah's empire.

To arrest the rot and recharge his supporters, the ayatollah whipped up nationalistic and religious feelings -- hence the troubles with the Kurds, the Iraquis and, in the Grand Mosque of Mecca itself, with Saudi Arabia. But the best way to revive the flagging revolutionary zeal of his followers was for the ayatollah to set himself against the enemy they all hated -- the deposed shah. And to get at the shah, it was opportunity to take on the ailing monarch's old friend and protector, the United States.

Given his itch to curry disfavor with this country, American efforts to discuss grievances and make accommodation in the therapeutic style of the State Department under Cyrus Vance were bound to fail. The soft response at the outset did worse than not succeed. It meant missing an opportunity to halt the spread of a disease that later surfaced in Pakistan. It also caused the ayatollah to up the ante -- dismissing the secular government of Mehdi Barzagan, rejecting all foreign intercession and increasing the number of students in the streets and the intensity of their demands.

The tide turned only when the pressures began mounting on Iran. The United States preempted moves the ayatollah wanted to make by cutting off oil purchases and freezing Iranian assets. Almost all countries condemn the Iranian breach of diplomatic immunity. Anwar Sadat of Egypt and leaders of other Islamic nations asserted in the strongest terms that the holding of innocent people as hostages was not in accord with the Creed of the Prophet.

The latter point, especially, made it clear to the ayatollah that he needed some reason for holding the hostages. Trying them as spies provides one justification. But not all can possibly be spies. Hence the release of some blacks and women as a "humanitarian" gesture.

The shifting of ground by the ayatollah points the way to an eventual outcome. In the next week or two, the shah will probably be well enough to leave the hospital in New York and return to Mexico. At that point the United States will have lost jurisdiction over him. A strong case can be made that there is no point in holding the hostages anymore.

But that outcome can be achieved only if the pressure on Iran is maintained. To that end, it is very important to keep up the steady insistence by Islamic leaders that the holding of hostages is not part of the Creed. For the ayatollah is best deterred from rash action by evidence that he has acted wrongly by his own logic.

As to the United States, this country needs to treat Iran as an outlaw state -- applying economic and military sanctions in a deliberate way. There is a danger that a moralistic president, having been hesitant to use force at the outset, will now -- especially with public opinion behind him -- try to compensate for earlier underreaction by a one-shot use of force that is both excessive and void of political objectives. So it is important to remember that military measures need to be taken in a political context. The objective, to be very specific, should be the removal of regime that threatens international stability and the establishment in its place of a moderate government.