The few people left in this small farming village say it was shortly after midnight a few months back when the red-hooded guerrillas of Sendero Luminoso brought their revolution here from the mountains.

The former mayor, the local civil clerk and a prominent landowner were dragged from their homes and summarily shot in the head. The local post office was blown up, and the grocery store was sacked. A red flag was raised in the weedy central square.

Then, four townspeople were summoned to have their hair shorn in front of a crowd as a warning against showing resistance to the peculiar Maoist doctrine the revolutionaries are trying to breed in the Peruvian Andes.

"It is not a thing that you want to talk about," said one of the punished, a middle-aged shopkeeper. "Everyone here still has a lot of fear."

That incident was in fact only a hint of the terror that has since descended all around the brown, arid mountain slopes and high plateaus of Peru's southern Andean departments. After almost three years of sporadic guerrilla warfare, the rural-based insurgents known as Sendero Luminoso (Shining Path) and Peruvian security forces have kindled an explosion of violence in one of South America's most backward regions.

Once haphazard, small-scale hostilities have suddenly turned into ruthless repression and massacres. "It is the law of the jungle," said a military official in the department capital of Ayacucho, 20 miles southwest of here and 350 miles from Lima. "Order breaks down and everyone lives by the rule of the strongest."

It was the poverty and official neglect of the mostly Indian Andean communities that helped inspire the Sendero Luminoso. Founded by radical professors at the University of Huamanga in Ayacucho in 1970, it has grown to between 500 and 1,000 members nationwide.

The group began as a regional splinter from the then-pro-Peking Peruvian Communist Party, adopting a strict Maoist ideology but rejecting ties with any of Peru's many leftist parties and organizations. Along the variegated ideological spectrum of Latin America, Sendero stands alone, apparently without outside allies and seeking none.

After 1980, Sendero concentrated on building a base in the old Inca territory of the Andes, in isolated rural centers whose names evoke a way of life worlds away from the mainstream of this country of 18 million: Uchuraccay, Lucanamarca, Huanca Sancos, Chuschi, Juiguisa.

For centuries, these small, poverty-ridden communities have been as alien and inaccessible as their Quechua Indian language to the urban masses of the Pacific coast, where a small, mostly white elite based in Lima has dominated Peru since Spanish colonial times.

Guerrilla warfare with relatively few casualties brought many of the highland villages under Sendero control, with little challenge from the Lima government of elected President Fernando Belaunde Terry. The first shocks of mass violence came in January, when the Army launched an offensive against the insurgents. In some of the Sendero-controlled villages the people suddenly began to attack and kill Sendero members.

As the violence spread, a group of eight Peruvian journalists was slain and mutilated on Jan. 26 in an Indian community that had been urged by the government police to attack the insurgents and apparently confused the journalists with the Sendero activists.

The Belaunde government appointed a prestigious commission to investigate the incident, and the subsequent report depicted a region "where in the struggle for survival anything goes and it is accepted that one kills first or dies."

That was only the beginning. Early last month, guerrilla forces, under pressure from both rural communities and aggressive government forces, slaughtered 67 civilians in one defiant village south of Ayacucho, according to government accounts. Since then, more than 30 other persons have allegedly been slain in guerrilla reprisals.

At the same time, the approximately 5,000 police and soldiers operating against the insurgents under a new military government in the area appear to be stepping up their own harsh tactics.

In all, more than 650 persons have been reported killed so far this year in Ayacucho and two other Andean departments, compared to 166 deaths recorded by the government in the violence during the previous 2 1/2 years. More than half died in April alone, and at least 142 of the victims were civilians.

The government security forces have reported killing more than 150 persons in sweeps, described as "intelligence operations," to root out suspected Sendero members in isolated villages.

"The situation in the countryside is being stretched farther and farther," said Jaime Urrutia, a university professor and rural program director in Ayacucho. "The terror is mounting and the violence is becoming more complex. The rural communities are withdrawing into themselves and growing aggressive against anyone outside."

The presidential commission also emphasized the alienation of the people in this area from the rest of the country. These people, the report said, "without water, without light, without medical attention, without roads that connect them with the rest of the country . . . in the high, inhospitable land of the mountains where they have lived isolated and forgotten since pre-Hispanic times, have known only the most despicable aspects of western culture, ever since the republic was founded . . . . The notion of achievement or progress itself should be difficult for them to conceive."

Sendero by last year had forced police, mayors and all other government representatives to withdraw from almost all of the 25,000 square miles of territory in the Ayacucho department, leaving dozens of communities under the effective rule of the insurgents.

The Maoists apparently followed a strategy of isolating the city of Ayacucho and other towns. They prevented farming communities from taking their goods to market, destroyed communications and killed local merchants and leaders.

Belaunde, who had long sought to downplay the growing violence as a police problem, did not act until last December, when the guerrillas blew up a bridge connecting Ayacucho with the southern half of the department. All civilian government authorities, including the rector of the university, were driven out of town by a series of shootings and assassinations. Belaunde declared the zone under martial law, and before long the undermanned and ill-disciplined police force based in Ayacucho was reorganized, reinforced and sent out on the offensive.

"What happened before is that we were sitting in our barracks in a defensive position, and now we are on the attack," said Commander Armando Mellet, the chief of the special antiterrorist squads of the national police that have done most of the fighting. Heavily reinforced police garrisons have returned to 13 rural posts previously abandoned in the department, and attack forces have begun descending in helicopters on the remote guerrilla-controlled towns to "clean" them of insurgents.

In Ayacucho, painted revolutionary slogans have been scraped off the white plaster walls and replaced with anti-Sendero cartoon drawings. Police who used to lounge in the central square and recklessly fire volleys into the air each night have been shaped up and banned from drinking. Army units have undertaken small public works projects and supplied food to the rural towns in an effort to win support from a population traditionally hostile to outside authority.

The presidential commission sharply criticized the security forces for past abuses, and other observers charge the forces with indiscriminate mass arrests, torture and ruthless killing of Sendero suspects.

Journalists and other independent observers have been barred from entering most of the remote regions where the antiguerrilla teams operate, but police authorities concede their activities have turned from confronting Sendero units to seizing suspects identified by informers as Sendero members.

A series of terse official communiques in recent weeks announced dozens of Sendero deaths over a period of days in unspecified areas, while reporting no casualties in government forces. "Sure there are abuses--in all situations like this there are abuses," said Mellet. "There is resentment in the public because in reality when you come to establish--or reestablish--the order of law in a place, you have to adopt positions with a little more force than usual."

Sendero leaders, for their part, appear to have taken up a new strategy of terror as their rural base has slipped. A series of villages rebelling against the insurgents' authority and their punishing economic doctrines have been brutally attacked during the past month. In some cases, Sendero has appeared to exploit traditional rivalries among the Indian communities. Some attacks have been carried out with the help of peasants who, apparently using the political violence to settle old scores, seized cattle and land.

The result has been that dozens of small towns have begun to feel threatened on all sides. In Huamanguilla, which is still claimed by the guerrillas as a "liberated zone," residents say antiguerrilla squads have come to the town twice in the last four months to carry out mass searches, arrests and allegedly brutal interrogations.

Now, the village appears virtually deserted. More than half of the residents, said Mayor Juan Contreras, have fled to Ayacucho and Lima, and even Contreras has moved out of town. He now commutes each morning from Ayacucho to watch over a town hall and a central square where only one small cafe remains unshuttered.

"Everyone here is fearful," he said. "There are no politics here. But all we have received has been abuse, robbery, repression and mistreatment."