The Reagan administration, battling to curb a rising tide of terrorism against U.S. interests in the Middle East, has unexpectedly turned for help to a man widely viewed as a consummate practitioner of this violent diplomacy: President Hafez Assad of Syria.

The bizarre new relationship developing between Washington and Damascus is one potentially significant outcome of Assad's crucial role in freeing 39 Americans from Trans World Airlines Flight 847. It represents an abrupt about-face for U.S. diplomacy, one that is unsettling to America's closest ally in the region, Israel.

Less than two years ago Syria was America's archenemy, berated as the eminence grise that, together with Iran, was held responsible for the spate of spectacular terrorist attacks on the U.S. Embassy and Marine barracks in Beirut that helped to drive the United States completely out of Lebanon.

Suddenly, President Reagan has dropped Syria from the list of "terrorist states" engaged in "acts of war" against the government and people of the United States. Instead, Assad has been praised for his help in ending the Beirut hostage crisis peacefully and cited as the man who holds the key to gaining the release of seven Americans kidnaped earlier.

The irony of U.S. praise for Assad -- particularly from a conservative administration that has been prone to paint the outside world in stark, black-and-white hues -- was not lost on American diplomats. "We want them to be wearing either a black hat or a white hat, and we have great difficulty dealing with someone with three hats always changing," one U.S. official remarked.

Assad is clearly a man of many hats.

The Syrian leader's double role and image seem all too fitting. He long ago learned how to use a bewildering array of proxies to work his will through violent means in Lebanon and against his other Arab friends and foes, even as he seeks to project himself as a peacemaker and worthy ally.

"Assad doesn't eschew terrorism on humanitarian grounds. He's amoral on terrorism," one U.S. analyst said. "He looks at terrorism tactically and we generically."

In a speech in early May to a youth congress in Damascus, Assad suggested that he holds almost a religious faith in the value of martyrdom, and fully believes in the use of suicide terrorists to kill his enemies. Reminiscing about the glory of the "suicide squads" the Syrian Air Force organized when he was a young pilot, Assad said he hoped "my life will end only with martyrdom . . . . I point to the greatness and preference of this end for any person."

Yet, it is precisely Assad's keen sense of self-interest and cold, calculating ruthlessness -- typified by his bloody crackdown on his own Sunni Moslem fundamentalists at Hama in March 1981 at a cost estimated by some reports at up to 20,000 lives -- that the administration hopes to exploit to enlist his support for its own war on terrorism in the Middle East.

"We don't pretend we agree with Syria on all issues. On broader issues of the Middle East peace process, we have considerable disagreement," national security affairs adviser Robert C. McFarlane said at the end of the hostage crisis. "But this issue terrorism is terribly important in a global sense and to the extent Syria can help and has we welcome that."

No Arab leader is potentially better placed to help. Assad has woven an extensive network of ties to almost every militia group operating in Lebanon today, including all of the main Iranian-backed Shiite ones. He has good relations with Iran, and the Shiite extremists operate in Lebanon solely at his sufferance.

His skillful manipulation of this network, like a master puppeteer, was never better illustrated than during the TWA hijacking and the 17-day ordeal of the 39 American hostages in Beirut. A telephone call to the Shiite Moslem leader Nabih Berri was all it took initially for the Amal militia to become involved in taking over most of the hostages from the original hijackers.

In the end, Assad succeeded in having the Americans freed by summoning Berri to a secret midnight parley in Damascus, mobilizing a visiting Iranian delegation to bring pressure on recalcitrant Shiite extremists, and finally sending a top security officer to Beirut to read the riot act to those refusing to hand over the last four hostages.

In the process, he signaled his readiness and ability, both to Iran and the Shiite extremists, to rein them in.

This in turn has raised the possibility that Assad could become a highly valuable, if unsavory, ally in the administration's war on Iranian-inspired Shiite terrorism throughout the Middle East.

In fact, U.S. policy makers are hard at work trying to identify and make use of what one called "a fleeting tactical mutuality of interests" between Syria and the United States, while painfully aware of the vast distance that separates the two governments' basic policies on everything from terrorism to the Middle East peace process.

Few seem to think the new U.S.-Syrian relationship is destined to go much beyond tacit cooperation over Lebanon, so opposed is Assad to overall U.S. policies in the Middle East. However, the vast improvement in relations the past two years between the United States and Iraq, once also branded a "terrorist state," suggests that radical shifts in friendships can, and do, happen in that volatile region.

A change is possible now because of the rising tide of Islamic fundamentalism, among the Moslem minority of Shiites in particular, that threatens to engulf Lebanon and challenge Syrian authority in a country Assad regards as part of a "greater Syria," and of vital interest to its security.

Assad, who fears his own Sunni fundamentalists at home, has an interest in discouraging the rise of Shiite extremists in Lebanon, U.S. officials say, particularly since those fundamentalists have begun aiding their Sunni brethen in Syria. Furthermore, Assad's Baathist ideology is totally secular and based on a separation of church and state antithetical to Islamic fundamentalist thought.

U.S. policy makers are hoping to exploit Assad's special relationship with Lebanon to persuade him first to pry the seven remaining American hostages out of the hands of Islamic extremists and then to crack down on "these crazies."

In effect, they are saying to him, as one administration official put it, "If you the Syrians are going to be directly responsible in Lebanon, by God we are going to come to you. We are going to hold you responsible for what happens in Lebanon."

U.S. officials do not hide their hopes of seeing Syria maintain its distance from Iran in the process of asserting its control over Lebanon. In fact, they seem to feel the two are headed for an inevitable showdown, since they are competing for influence, supporting different allies and pursing conflicting goals in Lebanon.

"Hopefully, an incremental wedge can be driven between them," a U.S. official said. "The U.S. interest is to drive a wedge."

The stage now seems set for a Syrian crackdown on the Shiite extremists groups that could serve as this wedge, free even of any U.S. manipulation.

The hostage crisis produced signs of a new Syrian determiniation to take control of the chaotic Beirut situation, in part through a closer alliance between Assad and the mainstream Amal Shiite militia under Nabih Berri. A U.S. green-card holder once married to an American, Berri provides a natural common link between U.S. and Syrian policies in Lebanon.

Berri leads the secular wing of Lebanon's Shiite movement. Syria, the United States and even Israel have a common interest in seeing Berri's faction prevail over the Iranian-backed Islamic extremist factions that have been challenging his leadership with increasing boldness.

The first signs of Assad's new approach are already visible. He has virtually dictated to the feuding Moslem militias a new security plan for West Beirut and the airport, placing its own security officers on a coordinating committee set up to see to its implementation.

Lebanon's incessant sectarian feuding has undone similar Syrian-designed plans in the past and could do so again, unless the Syrians decide to force compliance.

U.S. officials are heartened by new signs of Syrian determination in Lebanon's Bekaa Valley, where they are tightening their hold over the activities of the Iranian Revolutionary Guard and groups like Hezbollah, the Party of God, deemed responsible for the TWA hijacking.

U.S. officials are waiting to see whether Assad believes that the time has finally come to apply strong-arm tactics in the Lebanese capital. If he does, one of the main breeding grounds for the terrorism theatening U.S. interests in the Middle East might finally dry up -- or at least be brought under outside, albeit Syrian, control.