The battle began when a 300-man anti-Sandinista guerrilla force sneaked over a grassy ridge and opened fire with rifles, mortars and rocket-propelled grenades on a company of Nicaraguan soldiers defending this mining town.

It ended two hours later, when Soviet-made Mi8 and Mi24 helicopter gunships whirred in and unleashed a spray of machine-gun and rocket fire that routed the rebel attackers and left about 30 dead, by the Sandinistas' count.

The brief combat here in Nicaragua's Chontales province, described by Sandinista soldiers who participated and civilians who lived through it, was only one of many clashes during the last four years. But it goes a long way to illustrate the recent course of the guerrilla war being waged by U.S.-backed rebels to overthrow the Sandinista government in Managua.

The Popular Sandinista Army, advised by Cuban officers and supplied through Soviet allies, has altered its size, tactics, organization and equipment significantly in the last two years to repel the guerrillas with increased speed and force, according to Nicaraguan officials and other military sources.

The main rebel organization, the Honduras-based Nicaraguan Democratic Force, has suffered from a cutoff in CIA funding and logistical support during roughly the same period. As a result, according to these assessments, the rebels have been unable to resume the high level of attacks reached in the summer and fall of 1984 or to meet the ambitious goals set for 1985 by their leaders in Honduras and Miami.

"They have entered a defensive process," Defense Minister Humberto Ortega said recently, in what may prove to be a premature victory claim.

The rebel military leader, former colonel Enrique Bermudez, and the chief political figure, Adolfo Calero, said last August and September that almost all of their combatants were leaving Honduran camps and infiltrating into Nicaragua for what they said would be intense attacks.

Spirits were high then because of two successful attacks in July and August, one on the Pan-American Highway at La Trinidad and the other on Army troops at Cuapa just west of here.

In addition, Congress had renewed overt U.S. aid. The $27 million was limited to nonlethal items. But the rebel leadership hoped that the accompanying political endorsement would help bring in other money to pay for enough guns and bullets to end the relatively inactive winter of 1984-85, when most guerrilla forces holed up in Honduras.

Since then, the Sandinista Army has deployed thousands of troops along the border, particularly around infiltration routes in northern Nicaragua. Although mostly draftees, many of these troops have been trained as Irregular Warfare Battalions to conduct long-term patrols in the mountainous terrain.

According to Sandinista accounts confirmed by reliable informants, the 60,000-strong Popular Sandinista Army has formed a dozen of these battalions, and their presence in the northern mountains has largely frustrated the rebel attempt to infiltrate large numbers of combatants this fall.

In addition, these sources said, the Nicaraguan Army has begun to use helicopters with increased frequency and efficiency, particularly in clashes such as the one here on Nov. 19. The Sandinista Army has acquired a half dozen Mi24 gunships and at least 12 of the similar Mi8 helicopters equipped with machine guns and rocket pods, according to diplomatic estimates.

"What has changed our strategy more than anything else is the helicopters," rebel leader Calero said in a telephone conversation from Miami.

Calero said a Sandinista helicopter was shot down Monday by a rebel wielding a shoulder-fired SA7 antiaircraft missile north of here. The Soviet-designed missiles are available in the international arms trade. The Defense Ministry here announced Thursday night after an investigation that an Mi8 helicopter was shot down by rebel antiaircraft fire, probably an SA7 missile, with the loss of 14 soldiers.

Although the Sandinistas have lost helicopters previously, the downing of a helicopter with the recently acquired missiles marked a first for rebel forces that could force the Army to use the valuable aircraft more conservatively.

Several thousand rebel combatants -- called contras here, from the Spanish for counterrevolutionaries -- have been operating this fall in the lush ranch land here north of Lake Nicaragua and in the rugged mountains farther north. They belong to the Jorge Salazar Operational Command of the Nicaraguan Democratic Force, according to both rebels and Sandinista officials.

Army Chief of Staff Joaquin Cuadra, in an assessment confirmed by other military sources, said the rebels in this area appear to have two objectives. The first, announced recently by Bermudez on the rebel radio, is to threaten the Rama Road, over which the Sandinista Army transports military equipment shipped into the Atlantic port of El Bluff. The second, he said, is to draw Sandinista forces southward, hence relieving pressure on the infiltration routes.

Rebels have said they have more than 15,000 armed men, most of them in Nicaragua. Other sources, here and in Honduras, have put the figure at about 11,000, with 6,000 inside Nicaragua.

The swift expansion of the Popular Sandinista Army through conscription, although effective militarily, has aroused opposition among many Nicaraguans. Many of those recruited by the rebels have fled the draft at home.

Similarly, escalation in military equipment also has brought a political price. The helicopters whose fire turned back the attack here, for example, also let loose several wild rocket rounds, injuring half a dozen civilians, according to Sandinista soldiers and local residents.

Carmela Vasquez, 70, said her grandchildren Rebecca, 5, and Johnny, 2, were among five persons injured when an explosion in the garden of her small grocery store sent shrapnel flying.