PRESIDENT REAGAN, caricatured through much of his political career as a reckless gunslinger who would shoot first and ask questions later, succeeded in the Lebanese hostage crisis by doing exactly the opposite of what his most bellicose rhetoric suggested he would do.

Soon after the capture of the passengers on TWA Flight 847 confronted him with the potentially most damaging crisis of his presidency, Reagan learned the practical difficulty of making good on his 1981 vow to take "swift and effective retribution" against terrorist acts.

Yet by doing the right thing -- negotiating instead of attacking -- Reagan also did well politically. A Washington Post-ABC News poll shows that 72 percent of Americans approved of Reagan's handling of the hostage crisis, the kind of support one usually finds for motherhood resolutions. His approval rating also soared, and 66 percent now favor the way he is handling the presidency.

These high ratings do not sit well with the president's most conservative supporters, who would prefer a president who has more than talk in his antiterrorist arsenal. The hard right is deeply disappointed that their hero has abstained from retaliatory action against either the Mideast hijackers who killed a Navy diver or the terrorists who shot to death four Marines and nine civilians in an El Salvador restaurant on June 19.

Some conservatives have learned that their favorite slogan, "Let Reagan be Reagan" has different meanings than they imagined. The learners may have included White House communications director Patrick J. Buchanan, who as a conservative columnist during Reagan's first term often blamed pragmatic White House aides when the president's actions conflicted with his advocacies.

After Reagan rejected a proposal of Buchanan and political adviser Edward J. Rollins to retaliate against the Salvardoran killers of the Marines on the grounds that innocent civilians might be harmed, Buchanan reportedly told friends that Reagan was far more reluctant to use force than he had realized before he joined the White House team.

The president had lots of pragmatic company last week when the lives of 39 American hostages were on the line. Secretary of State George P. Shultz cooled his fiery rhetoric about the need to retaliate against terrorists even at the possible cost of civilian lives. National security adviser Robert C. McFarlane, who had backed Shultz and supported retaliation after the October 1983 Beirut bombing that killed 241 Marines, stressed diplomatic negotiation and opposed military options.

Even White House chief of staff Donald T. Regan, whose tough talk has sometimes matched the president's, favored a restrained response to the terrorists. Regan opposed the retaliatory advocacies of Buchanan and Rollins, and genially referred to them as "the mad bombers."

In 1980 Reagan used the "mad bomber" phrase to characterize the campaign portrayal of him by President Jimmy Carter. Most of this depiction was directed at Reagan's views of the Soviet Union, but it also spilled over to the Iranian hostage issue. One of the gallows humor jokes of that campaign was, "What's a foot high and glows in the dark?" The answer was, "Iran after Reagan becomes president."

Reagan's strategists had a dualistic view of such sallies, which simultaneously suggested that he was decisive and dangerous. They tried to downplay the menace in this equation while reinforcing the idea that Reagan would be a stronger leader than Carter.

Reagan himself appeared to have no doubts and even less understanding. He called Carter's handling of the Iranian issue "a humiliation and a disgrace," and in the heady aftermath of his landslide victory appeared certain that such humiliations were a thing of the past.

Welcoming home the Irananian hostages on Jan. 27, 1981, six days after his inauguration, Reagan declared: "Let terrorists be aware that when the rules of international behavior are violated, our policy will be one of swift and effective retribution. We hear it said that we live in an era of limits to our powers. Well, let it also be understood, there are limits to our patience."

In 4 1/2 years of the Reagan presidency, there has never been agreement within the administration on the definition of these limits or what should be done when they are exceeded. Debating thorny questions of retaliation and reprisal, Reagan has learned by mistakes and experience that the view is different from the Oval Office than from the stump, and that campaign simplicities have little relevance to the actual decision-making of a president.

It is not a new lesson. John F. Kennedy became president and discovered that the "missile gap" which he had campaigned on did not exist. Richard M. Nixon became president and proved to have no plan, secret or otherwise, for speedily ending the Vietnam War. Jimmy Carter became president and found that the Soviets were a lot more difficult than he had anticipated.

After the Soviets invaded Afghanistan, Carter said that the move "has made a more dramatic change in my opinion of what the Soviets' ultimate goals are than anything they've done in the previous time that I've been in office."

If Afghanistan was an instant eye-opener for Carter, Lebanon was a gradual learning experience for Reagan -- who was always more pragmatic and balanced than either his supporters or detractors acknowledged. Reagan's deeply held pro-Israeli views prevented him from discouraging the Israeli invasion of Lebanon in 1981, when Secretary of State Alexander M. Haig Jr., was calling the tune. After the invasion soured and the Israelis pulled back from Beirut, Reagan did not know enough about the situation in Lebanon to realize that the Americans had replaced the Israelis as the principal target of terrorism.

The learning period was a costly one for a president who had as long ago as 1976 vowed "no more Vietnams." In 1983 the president ignored the warnings of the Joint Chiefs of Staff and Secretary of Defense Caspar W. Weinberger, who worried that Marines would become sitting ducks if employed in static positions around the Beirut airport. Reagan instead accepted the counsel of Shultz and McFarlane that a U.S. presence in Lebanon could help stabilize the country.

The lesson that proved otherwise came when a suicide truck bomber struck Marine headquarters on Oct. 23, 1983, and killed 241 U.S. servicemen. This was the kind of attack that historically has caused U.S. forces to stay put to justify the sacrifices of the dead, and Reagan's rhetoric in the aftermath of the bombing was unyielding.

The actual U.S. response was, as always, more measured than the presidential speeches. But it also was unsuccessful. A raid against Syrian antiaircraft batteries in December 1983 cost the U.S. two planes, one pilot dead, and another flier left captive for a month. A bombardment by the USS New Jersey proved similarly ineffective and deepened anti-American feelings in Lebanon as the U.S. hostages from TWA Flight 847 discovered when they were shown pictures of the shelling.

But Reagan had learned from the failures of his predecessors in Vietnam, partly because military leaders and Congress also had benefited from the Vietnam experience. What he had learned most of all was that if you can't use the military force necessary to win a conflict, the best thing to do is get out. Prodded by Republican senators who didn't want to defend Lebanese intervention, Reagan withdrew U.S. forces from the embattled country while proclaiming everlasting support for the government of Amin Gemayel.

Reagan's ability to make sensible decisions that contradicted emotionally satisfying speeches was catching. Shultz led the administration in retreat before terrorism, while at the same time denouncing the evils of "state-supported terrorism."

"The public must understand before the fact that there is potential for loss of life of some of our fighting men and the loss of life of some innocent people," Shultz said in a speech Oct. 25 at the Park Avenue Synagogue in New York. "The public must understand before the fact that some will seek to cast any pre-emptive or retaliatory action by us in the worst possible light and will attempt to make our military and our policy- makers -- rather than the terrorists -- appear to be the culprits."

But it was the ghost of successful terrorism in Lebanon rather than this vivid warning that framed the debate within the administration after the hijacking of TWA Flight 847.

Everyone, it seemed, had learned something about the reality of dealing with armed terrorists. Even while pledging not to negotiate with the hijackers, Reagan and McFarlane quickly decided that military force was not an effective option.

The military had learned lessons of its own, ever since Vietnam. One important lesson was that options were limited under a policy that required "no collateral damage" -- the current military jargon for a strike that does not kill civilians. This ruled out a lot of responses in a hurry, particularly an attack in Beirut.

Even while U.S. ships were taking position off the coast of Lebanon, Adm. James D. Watkins, the U.S. chief of naval operations, was saying that he would subject any U.S. plan for attacking terrorists to a "moral checkoff list." Watkins and the other members of the Joint Chiefs of Staff are emphatic reminders that the United States has indeed drawn lessons from Vietnam, lessons that include the futility of waging a type of war that the American public no longer supports.

Both Reagan and the chiefs were guided by practical considerations. They recognized that thousands of American servicemen and civilians around the globe are vulnerable to acts of terrorism. They recognized also that the way to minimize casualties is to use overwhelming force, an alternative that had few supporters in the White House.

McFarlane, a Marine combat veteran of Vietnam who strongly favored the deployment of Marines in Lebanon and opposed their disengagement in 1983, had also learned some lessons. Directing the diplomatic efforts to free the hostages through the good offices of Syria -- offically listed by the State Department as one of the nations supporting terrorism -- McFarlane quickly ruled out military options to rescue the hostages or retaliate against the hijackers.

After the hostages were freed, McFarlane sounded even more dovish. Declaring that "venegeance is not a policy," he pointed out that the militant Shiite sect Hezbollah, which the United States holds responsible for the hijacking, was protected from direct reprisal because it takes refuge in the urban population of Beirut.

The fact that terrorists swim in a civilian sea would have given neither them nor the civilians much protection in Vietnam. But Reagan, always more tender-hearted when dealing with real people than with abstract ideas, decided that retaliation in which innocent civilians are killed is "itself a terrorist act" -- a view he expressed publicly at his June 18 news conference. Rollins and McFarlane tested this view two days later when the Marines were killed in El Salvador and they proposed a retaliatory strike in response.

Reagan's response showed how much he had learned -- and how little he conforms to the gunslinger caricature. He asked McFarlane whether an attack could be carried out without killing civilians -- a yardstick that surprised Buchanan. When McFarlane said no, Reagan ruled out retaliation and settled for a tough-sounding statement read next day in the briefing room by White House spokesman Larry Speakes.

Reagan did much the same when the Lebanese hostages were freed. He made a speech from the Oval Office promising to "fight back" against terrorism but did nothing more than offer a bounty for capture of the hijackers.

Warming up for that speech, Reagan quipped over an open microphone, "After seeing 'Rambo' last night, I know what to do the next time this happens." Those who have seen Reagan in action are not so sure. An administration official who discussed possible options for reprisal last week seemed to be saying that Reagan wouldn't approve most of them. Beirut was out because of the civilians. Syria was out because President Hafez Assad had freed the hostages. Iran was out because the Iranians, too, showed some sign of helping and attacking Iran would encourage the most radical elements in the regime. Even the Shiite military complex at Baalbek in eastern Lebanon, the favorite target when the Israelis want to retaliate, was doubtful because some or all of the seven kidnaped Americans in Lebanon may be held hostage there.

Reagan's more firebreathing supporters welcome his rhetoric about reprisals but are troubled by the practical lessons he has learned about retaliation. The Wall Street Journal used "Jimmy Reagan" as a headline on one critical editorial and concluded a black-bordered editorial about the murdered Navy diver Robert D. Stethem with the suggestion that the Reagan administration had given the hijackers amnesty for the crime.

New-right activist Richard Viguerie, who does not hestitate to criticize Reagan, maintains that the president has sacrificed his credibility.

"It's one thing to rank high in the polls with the American people and another to have the respect of world leaders," Viguerie said. "With each new crisis, Reagan has less and less credibility with both friends and foes."

Maybe so. But there are those who make the opposite argument from the same set of facts. They contend that "the next time" Reagan will be in position to retaliate just because he has proved so prudent in the recent hijacking crisis and has freed himself from the suspicion that he is potentially trigger-happy.

"It is very clear to people now that Ronald Reagan is not a gung-ho cowboy whose goal is to drop bombs on people," said a senior administration official last week. "He's restrained. He would have great credibility if he were in a situation where he had to take forceful action. People would believe he had tried other alternatives first."

What this amounts to is that the same people who used to reassure skeptics that Ronald Reagan wouldn't start World War III are now telling anyone who will listen that he's not the pussycat he seems.