Peru's armed forces, under pressure from President Alan Garcia, have admitted that at least 40 peasants in an Andean village were killed by troops in a counterinsurgency operation last month. Two generals in direct command of field operations in the central Andes were relieved of their posts last night, and officers and troops implicated in the massacre are to be put on trial.

During the past three years in which the military has led the fight against Maoist guerrillas in the Andean highlands, investigations into charges of human rights abuses have been blocked by politicians' fears of being overthrown. Elected governments have handled the military with extreme caution, especially since there were coups d'etat here in 1948, 1962 and 1968.

Social scientist Luis Millones said, "For the first time in Peruvian history, a civilian president has dared to redefine the relations between the government and the armed forces."

The new president appears to have handled the disciplining of the military successfully thus far. He issued a major statement on Saturday, setting up a commission to investigate the human rights charges. Sunday's dismissal of the chairman of the Joint Chiefs of Staff, Air Force Gen. Cesar Enrico, was announced in a government communique. All other announcements were made by the armed forces. In effect, the military is cleaning up its act by itself, observers here said.

Last night, Air Force Gen. Luis Abram, the new chairman of the joint chiefs, announced on television that an Army patrol had killed at least 40 peasants near Accomarca, 430 miles southeast of Lima, on Aug. 14. He said that generals Sinesio Jarama and Wilfredo Mori, the two commanding officers of the Ayacucho emergency zone, had been relieved of their posts. Abram said that all officers and soldiers involved in the incident would be put on trial.

Only hours before their dismissal, generals Jarama and Mori had appeared before a Senate investigating committee and denied that the incident at Accomarca had taken place. They said any bodies found in the area were from clashes between guerrillas and troops or militia. The military communique later explained their misleading testimony by saying that "a noncommissioned officer had not included the incident in his report."

The armed forces' denial of the Accomarca incident was shattered by reports from Ayacucho, where members of Congress had been conducting investigations. Left-wing congressman Jorge Tincopa told a television journalist that he had come across three elderly women and a girl in Accomarca who had witnessed a seven-day sweep through the isolated region by Army patrols from the Vilcahuaman and Cangallo bases. They told him that troops had pillaged and burned food supplies, belongings and homes, raped women and then shot the peasants and burned their bodies. Tincopa said 57 peasants, 27 of them children, were killed. He dug up one of three graves near the town of LLoqllapampa and found "charred human remains."

The government's new stand on human rights already is having an impact in the Ayacucho emergency zone. Delegations from peasant communities are coming down from the highlands to present complaints against security forces and militia units from rival communities. The charges include pillaging, theft and kidnapings.