Rifle barrels clicked against each other on the crowded dance floor last week as leftist Salvadoran guerrillas and their peasant supporters threw a party on the porch of a long-deserted hacienda here.

The only light came from two camping lanterns. In these heavily forested mountains, as in other rebel strongholds, electricity has been lacking for years. The civil war has reduced most of the isolated, mud-brick houses in the area to overgrown, crumbling ruins linked only by narrow trails.

The guerrillas were celebrating the return to their ranks of five comrades released from prison the previous week as part of an exchange in which President Jose Napoleon Duarte got back his kidnaped daughter. A guerrilla leader here, Leonel Gonzalez, said the deal showed that the rebels were winning their fight against the U.S.-backed government.

"The enemy is suffering a severe crisis," he said. "Our comrades are here as the product of the advance of our forces."

The assembled guerrilla fighters, political organizers, field nurses, radio operators and poor farmers readily accepted Gonzalez's analysis. They lustily chanted slogans such as "On toward the final victory!" and "We will win!"

Despite their apparent optimism and determination, however, El Salvador's revolutionaries are under siege. Jet bombers, helicopters and well-armed infantry units regularly attack this "zone of control" and the rebels' four other principal base areas in the Salvadoran countryside. Just a few hours before the party began, Army mortars bombarded a ridge line five miles from here.

The Army's elite Belloso Battalion, advancing from the west, already had begun the eighth government sweep through these mountains this year. Government helicopters and reconnaissance planes had made observation flights in the morning, and rebel sentries were posted to shout for the lanterns to be extinguished if any aircraft approached. Helicopters had rocketed and strafed the nearby hamlet of Jocotio four days earlier, breaking tiles on several roofs, according to two residents of that village.

Government troops, particularly the feared Atlacatl Battalion, burn crops, household goods and homes during attacks almost every month, according to interviews with dozens of residents conducted during a rare nine-day trip behind guerrilla lines here in the northern province of Chalatenango.

In violation of government rules against attacks on civilian targets, aircraft periodically bomb, rocket or strafe villages even when no armed guerrillas are around, the residents said.

The number-two guerrilla leader here, known by his nom de guerre Dimas Rodriguez, mingled with the crowd of about 150 on the evening of the party. A thin, nervous military specialist, he led a successful assault on the nation's largest dam and hydroelectric plant in June of last year.

Gonzalez, the zone's top commander, is a former elementary school teacher and union organizer. He is a formal, retiring sort who slipped away before the three guitarists and bass player began their medley of revolutionary and traditional folk tunes.

Officials of the local rebel administration and armed militiamen escorted me and four other U.S. citizens during the tour, but we were free to speak with anyone privately. The local rebel officials and other residents acknowledged that the Salvadoran government armed forces' behavior had improved this year, noting in particular that troops had not staged a large-scale massacre in the area since, they said, 40 civilians were stalked and killed 14 months ago along the Gualsinga River near here.

The government armed forces spokesman, Lt. Col. Carlos Aviles, in a subsequent interview in the capital, San Salvador, said the military did not target civilians in inhabited zones, but he added that eastern Chalatenango was "depopulated" and that the rules in such areas were "not exact."

It appears that the armed forces consider the area to be empty of civilians because the rebels' peasant supporters, called masas or "masses," hide in the mountains whenever troops approach.

Confronted by the government's military pressure, thousands of rebel supporters and relatives have fled this zone and other rear-guard areas in the past two years for refugee camps or towns in no man's land where the armed forces are less aggressive, according to officials of the local revolutionary government here and to international relief workers.

This exodus cuts into the pool of organized peasants who grow food, sew clothes, carry supplies and spy for the guerrillas. A maximum of 25,000 civilians -- one-half of 1 percent of the nation's population -- currently live in areas that normally are under rebel control and actively work for the guerrillas.

In addition, the election of Duarte last year, accompanied by a modest, U.S.-backed purge of military officers involved in "death squad" activities, has bolstered the government's prestige at home and abroad. The guerrillas' image has suffered this year because of increasing attacks on civilians, including the kidnaping of more than 30 mayors and shootings of bus and truck passengers during nationwide transportation stoppages.

A guerrilla commando unit also killed four unarmed, off-duty U.S. Marine embassy guards and eight civilians and wounded six others in an attack on a crowded restaurant in June in San Salvador.

The Reagan administration has persuaded Congress to finance a major buildup of the military and particularly the Air Force, which the guerrillas cite as their most formidable enemy.

"Without the help from the planes, the Army wouldn't ever get in here," veteran peasant organizer Maria Serrano said.

Rebel leaders acknowledged that the situation has changed since 1982 and 1983, when the guerrillas drove out the National Guard outposts and Civil Defense patrols that once enforced the government's rule in what are now the "zones of control." In addition to northern and eastern Chalatenango, these base areas include the northern half of Morazan province in the east, the slopes of the Guazapa Volcano near the capital and areas in San Vicente and Usulutan provinces.

At a meeting of its five-man general command in July, the Farabundo Marti National Liberation Front, known by its Spanish initials FMLN, drew up new strategies to deal with what it termed the government's new style of counterinsurgency warfare. The FMLN is made up of five guerrilla armies, one of which is the Popular Liberation Forces headed by Gonzalez and based here in Chalatenango.

Gonzalez and the four other commanders agreed on new tactics emphasizing small-scale combat operations, kidnapings and political assassinations, and stepped-up organizational work with unions and refugee groups, guerrilla leaders said. In a tacit admission that they are on the defensive militarily, they said that labor agitation and other popular movements currently represent the "most dynamic" part of the revolutionary struggle.

The FMLN also agreed in principle to unite its often fractious five forces into "one single army," and to spread the war to new areas, particularly in the capital and the mostly peaceful western part of the country. Guerrillas have infiltrated through Chalatenango and have begun raiding military outposts in the western province of Santa Ana. They are seeking to open a front there just as they did here three years ago.

When viewed from this isolated retreat, the rebels' strong conviction that this strategy ultimately will succeed is easier to understand. The only people left here are militants with years of experience either in the guerrilla forces or in radical mass organizations, so the sense of commitment is continually reinforced, no matter what the reality may be elsewhere. People here routinely call the Army the "enemy," as in a query from a middle-aged peasant man about the whereabouts of the Belloso Battalion: "What's the enemy up to?"

The guerrillas, who usually live in secret camps that we were not allowed to visit, have few material needs and seemed to be adequately supplied. Each carries two sets of clothes and a few personal belongings in a small pack, and wears a flashlight, canteen and a few clips of ammunition on a belt.

When asked where they obtained their U.S.-made M16 automatic rifles and ammunition, the rebels invariably responded that their arms were captured from the enemy. When pressed, they did not deny that some of their supplies arrived via Nicaragua or other friendly leftist countries.

Two large burlap bags filled with cheap leather boots were seen at a supply post. They were said to have been smuggled across the nearby Honduran border.

Most importantly for their survival, both the guerrillas and their supporters have learned from dozens of government attacks how to defend themselves. The attacks, while frightening, appear to cause relatively few casualties.

Children as young as 10 are able to tell from the sound of an airplane when it is close enough to attack, and crude bomb shelters dug into earthen banks were visible near virtually every inhabited hamlet. Guerrilla patrols with walkie-talkies monitor the Army's movements and warn the people to get out of the way during sweeps.

Our group received reports twice a day about the Belloso Battalion's position, and we changed our itinerary once to steer clear of it. The other U.S. visitors were a photographer, a film maker, and the top two officials of a U.S. group that raises funds to buy medical supplies for clinics, mainly in guerrilla-dominated zones.

The last confirmed civilian deaths in Chalatenango occurred Aug. 6 when an air attack killed three noncombatants in El Ocotal, northwest of here. Previously a 40-year-old man was killed during a helicopter-borne assault on July 19. Guerrilla commanders declined to disclose their casualty figures but said they were "very low," an assessment shared by residents.

The guerrillas' political-military commander for Chalatenango, known as Ricardo, acknowledged that the war would be a long one now that the United States has committed its power to defending the Duarte government. He argued that the guerrillas still would win, saying that "all empires must fall."