The main highway running beside the rebellious city of Hamah was reopened to traffic today, but Syrian troops were still engaged in street fighting to dislodge Islamic extremists holding out in the city's ancient hillside alleyways.

The 13-day-old uprising appeared to be nearing an end, government officials said. Syrians and foreigners alike were barred from entering the city, however, and the officials acknowledged some of the well-armed Moslem rebels were still fighting back despite a major deployment of troops and armor.

The revolt in Hamah, a fundamentalist stronghold, has marked the most extensive armed opposition to President Hafez Assad's government in nearly three years of sporadic sedition, which officials have blamed on the fanatical Moslem Brotherhood aided from abroad.

But Syrian authorities and diplomatic observers here say the large-scale violence has been confined to Hamah, with no confirmed reports of open military revolt that would signal imminent danger to Assad's 11-year-old Baathist government. The loyalty of Syria's 220,000-man armed forces has long been considered crucial to Assad's power.

At the same time, the Hamah rebellion comes as the latest in a series of problems for Assad, a 53-year-old former jet pilot and Air Force commander. Foremost among them was Israel's Dec. 11 annexation of the Golan Heights, captured from Syria in the 1967 Middle East war. Despite widely shared outrage, Syria was unable last month to rally support for a hard-line U.N. Security Council resolution calling for mandatory sanctions against Israel. Then, last week in Tunis, Arab foreign ministers declined a Syrian proposal for an Arab economic boycott of Israel's main backers, particularly the United States.

Foreign reports, denied by Syria, also have spoken of officers being arrested last month in connection with antigovernment agitation. Information Minister Ahmed Iskandar put the number of those arrested at about 15, but he denied they had been involved in a plot against the Baathist government.

Taken together, the reversals seem particularly troubling against the background of repeated reports that Prime Minister Menachem Begin may be considering a new Israeli attack on Palestinian forces in Lebanon. A large-scale confrontation there would risk involvement of the 22,000 Syrian troops stationed in Lebanon to enforce a five-year-old cease-fire, and perhaps even direct Syrian-Israeli fighting.

The scale of fighting in Hamah since clashes broke out Feb. 2 also demonstrates that Assad's Moslem Brotherhood foes have access to modern, plentiful weaponry. Syrian authorities announced that troops found 500 submachine guns, 40 shoulder-fired rocket launchers with armor-piercing rockets and hundreds of smaller arms in brotherhood hide-outs.

Syrian sources said intelligence reports that led authorities to intervene had underestimated the rebels' strength. As a result, they added, what had been intended as a crackdown and a roundup of weapons turned into a fight. Unofficial reports said Syrian artillery and tank cannons caused considerable damage and that the rebels were driven into their hideaways in the ancient Hadhir area only after hard fighting. Several local officials and their families were murdered by extremists in the first few days of the uprising, the reports said, implying sections of the city of 300,000 had been out of control.

Although no casualty reports have been announced, unofficial Syrian and foreign diplomatic estimates say about 400 soldiers and hundreds of Hamah rebels have been wounded. A measure of the fighting, they add, is the deployment of Syria's 21st mechanized infantry brigade from the 3rd armored division and the 47th independent armored brigade along with units of the special Defense Brigades. The brigades, commanded by Assad's brother Rifaat, are considered the cream of Syria's armed forces.

Syrian troops have intervened to put down smaller extremist revolts in Hamah several times in the last two decades, on occasion attacking mosques where rebels sought refuge. The city is considered a center of the Moslem Brotherhood. Illegal in Syria, the brotherhood is accused by the government of being behind a series of bombings and assasinations that have troubled Assad's secular Baathist government since the spring of 1979.

Women customarily wear veils and follow Islamic strictures closely in Hamah, Syrians say, and stores selling alcoholic beverages have come under attack frequently by fundamentalists. Most of Syria, particularly Damascus, observes its Islamic faith tolerantly, with alcoholic drinks readily available and women frequently dressing in European fashions. Assad's Alawite minority plays a predominant role in the Syrian government and armed forces, leading to friction with the Sunni majority and particularly its extremist fringe in the brotherhood. Although this is not the only reason for disaffection from Assad's rule, the government charges the brotherhood with responsibility for the violence.