President Hafez Assad's ability to frustrate U.S. efforts to get all foreign troops out of Lebanon is bolstered by his apparent success in ruthlessly breaking political opposition at home and the weakness of Syria's opponents abroad.

While Israeli casualties in Lebanon mount, the Palestinians wrestle with mutiny in their ranks and Iraq agonizes in a seemingly endless war with Iran, Assad has never in his 13 years in office seemed so much in control.

Known as the "coup country" in the volatile first two decades of independence from France, Syria under Assad's rule since 1970 has become a country in which a half dozen domestic intelligence services and numerous agents seem to reach into all aspects of life.

The government is so confident that state-run television is running a series by long-banned Mohammed Maghout satirizing the brutality of the secret police and the privileges and corruption of the politicians. One middle-class housewife remarked about the series, "I don't know whether to laugh or cry."

The once serious challenge to Assad's power represented by the strict Islamic fundamentalist Moslem Brotherhood collapsed in the winter of 1982 when the government suppressed a rebellion in Hama. The city, about 120 miles north of Damascus, is a stronghold of the mainstream Sunni Moslem sect that makes up the majority here, although the government is run by the minority Alawite sect.

The death toll from the fighting in Hama may never be known. Estimates vary from many hundreds to more than 20,000, as claimed by the Moslem Brotherhood. Whole neighborhoods of Hama were destroyed in the fighting. So, too, for the time was an effective opposition force, according to political analysts who add, however, that new political events could help resurrect it.

What emerged from the Hama rubble, according to local residents, was a respect for the government in large part born of fear, but also of a feeling of avoiding even greater catastrophe. Some analysts have argued that the destruction of Hama, an antigovernment center since the days of the Ottoman Empire, marked the birth of modern Syria and the triumph of centralized power. Increasing numbers of Syrians, many of whom had not supported Assad or the ruling Baath Party, became frightened by the rash of bombings and other forms of violence attributed to the Moslem Brotherhood. The unwelcome prospect of dour theocratic rule along lines similar to those of revolutionary Iran reconciled many Syrians who previously had been critical of Assad..

Even many of the majority Sunnis preferred Assad, a member of the once reviled Alawite minority sect that accounts for perhaps 12 percent of the population and is viewed as heretical in some ultra-orthodox Islamic quarters. Sunni Moslems, making up at least 60 percent of the population, long chafed at their loss of power to the Alawites--who began their rise to political power by entering the French colonial army.

Assad is a former Air Force commander and his control of the military is considered so complete that not even last June's hammering by the Israelis during the invasion of Lebanon provoked any discernible discontent in its ranks. Despite the loss of a quarter of its combat aircraft and hundreds of tanks, the fighting last year is being depicted by Syrian propagandists as a victory.

Some military specialists say the 40,000 Syrian troops in Lebanon are in better fighting trim than at any time since Syrian soldiers first entered as an Arab League peace-keeping force in 1976. They attribute this to tightening of a loose discipline, associated with the Syrians' duty in the Lebanese capital, now that the force has been ousted from Beirut.

Although no large Syrian units have been rotated from Lebanese duty since November 1981, individual companies and battalions have been pulled out for training in Syria and some training is also done in Lebanon.

Syria has demonstrated in the past an ability to make do on its own. Saudi Arabia and other oil-rich Arab states would not relish being cast in the role of threatening to cut off aid to the only Arab army confronting the Israelis in the field.

Syrians may be far from happy, but many show a conviction that life in most other parts of the Middle East is appreciably worse.