THE long ordeal of American hostages in Lebanon is finally over, ending a trial that at times made the nation feel powerless. It profoundly affected the course of presidential politics and United States involvement in the Middle East.Behind the quick release of the three final US hostages was not specific action by the US or United Nations so much as a vast process of change in the Middle East that no one could have foreseen when the hostage-taking began. In the end, the hostages were freed because they had become a liability for their Shiite captors and the captors' sponsors, Iran and Syria. Elation at hostage Terry Anderson's freedom, and the freedom of all his fellow Americans, is tempered by remembrance that those who gave that freedom took it away in the first place. "We are very happy for Terry Anderson," said White House spokesman Marlin Fitzwater on Wednesday. "But it also brings home the sadness of the whole, long seven or eight-year ordeal." Of course, some might date the beginning of the hostage crisis not to the mid-1980s spate of Beirut kidnappings but to the takeover of the US Embassy in Tehran in November 1979. Public anger and frustration over the hostage standoff played a large role in the 1980 electoral defeat of President Carter. Ronald Reagan's administration was to prove no more adept at handling Middle East hostage situations, however. By all accounts the personal tragedy of the hostages weighed heavily, perhaps too heavily, on Reagan's mind. In the end the Reagan administration undertook the risky effort to sell arms to Iran in an effort to speed hostage releases - leading to the politically disastrous Iran-contra affair. President Bush, on the other hand, followed a policy of "benign neglect" toward hostages taken on the streets of Beirut, says University of Michigan political science professor Raymond Tanter. As a staff member of the National Security Council in the early Reagan years, Dr. Tanter wrote a paper proposing just such an approach, arguing that strenuous high-publicity efforts to win their freedom would only make them more valuable in their captors' eyes. But it was larger events that cleared the way for the end of the crisis, says Tanter: "The release was the spinoff of two wars: one cold, one hot." The end of the cold war and collapse of the Soviet Union meant Syria had lost its great power patron and needed a new source of technology and arms. The Gulf war established the US as the preeminent superpower influence in the region. Thus, the cold realities of geopolitics meant Syria must at least appear to shed its support for terrorist groups and hostage-taking and use its influence and growing control over Lebanon to work for release of the hostages. At the same time, Iran's effort to rebuild ties with the West was picking up speed. With the death of Ayatollah Khomeini in 1989, more pragmatic factions have solidified their political position in Iran and begun the long work of rebuilding an economy shattered by its decade of war with Iraq. Iranian leader Hashemi Rafsanjani has "been trying to improve his relations with the West for a very long time," says Shaul Bakhash, an Iran expert at George Mason University. "They behaved very well in the Gulf crisis" from a Western point of view. This week, the US paid Iran $260 million in a settlement of claims for arms impounded after the fall of the Shah. American officials denied it was a quid pro quo for hostage freedom. There are still major differences between Washington and Tehran. Iran, for instance, wants a place at the table when discussions are held about the post-Desert Storm security structure for the Persian Gulf. But, clearly, Iran decided the hostages were an impediment to its foreign policy, not an asset. The extent to which Syria and Iran control the extremist Shiite factions that held American hostages isn't entirely clear. The drawn-out nature of the hostage endgame suggests that neither Damascus nor Tehran can just pull strings and open prison cells in Beirut. But the Lebanese kidnappers themselves seem to have tired of the hostage game. "They just want to get rid of this burden," says Muhammad Faour, a professor at the American University of Beirut studying in Washington on a fellowship. Hizbullah, umbrella group for the Shiite factions, has moderated its rhetoric somewhat, says Dr. Faour. "They are not openly calling for an Islamic state," he says. "They are saying, 'we want more participation in the government by Muslims.