Until her attackers raised their weapons, stabbing her dozens, then scores of times until she died, Commander "Ana Maria" of El Salvador's Popular Liberation Forces probably believed they were her comrades.

Of the four aides and servants in the house where the former school teacher and labor organizer was staying just outside Managua, Nicaragua, three were allegedly in on the plot. The housekeeper was the first to break after being detained. The memory of the victim's screams would not allow her to sleep, she is said to have told investigators.

Other plotters were rounded up. The accused ringleader proved to be another top commander in the same guerrilla faction. Then, less than a week after the April 6 murder, the founder of the Popular Liberation Forces, Salvador Cayetano Carpio, reportedly committed suicide.

This bloody intrigue at the top levels of El Salvador's largest guerrilla faction brought a 13-year chapter in the history of the Salvadoran revolution, begun by Cayetano Carpio, to a bizarre close. But what it means to the future of the fight that continues and intensifies here is the subject of speculation and debate from rebel checkpoints on El Salvador's highways to the conference rooms at the U.S. Embassy.

A detailed and dramatic account of the killing only recently made available by leading members of the guerrilla movement suggests that the murder of "Ana Maria," whose legal name was Melida Anaya Montes, and the suicide of "Marcial," as Cayetano Carpio was called, were little more than a Euripidean denouement to a conflict decided months before.

But the U.S. Embassy has used the incident to revive an image of the guerrillas and especially of the Popular Liberation Forces, known by its Spanish initials FPL, as "the Pol Pot left." To reinforce this argument it makes the point that some of this faction's units were involved in two apparent massacres of several prisoners and in the killing of a U.S. military adviser.

But one of the most obvious divisions in guerrilla ranks revealed by the killing in Managua is simply between those commanders who are fighting the war and those who spend most of their time in other countries, many of them apparently living in Nicaragua more or less permanently, theorizing and debating about it.

A Popular Liberation Forces fighter in Chalatenango province, expressing little regret about the deaths in Managua, explained, "I wouldn't say that you don't feel the death of a man, but those who really make the war in this country, who order us to attack the enemy, are others. You don't meet our chiefs over there directing from outside."

Cayetano Carpio represented the most dogmatic, unbending ideological line in the broad spectrum of Marxist and other socialist views pulled together in the military Farabundo Marti National Liberation Front and the political Revolutionary Democratic Front (FMLN-FDR).

Cayetano Carpio, 63 at the time of his death, developed a cult around his Ho Chi Minh-like persona as "Marcial." He was the personification of the Salvadoran struggle in the eyes of much of the rest of the world, addressing such events as the Communist Party Congress in Havana in 1980.

He portrayed himself, said one moderate leftist, as "the oracle of the revolution" and from the time he founded his group as a breakaway faction of the Communist Party devoted to "armed struggle" on April 1, 1970, he resisted any change in his basic conception of the fight:

The revolution would have to be Marxist-Leninist and would represent the triumph of a worker- peasant alliance. Any other political allies were to be strictly "fellow travelers" used for tactical purposes. El Salvador's must be a "prolonged popular war" of low-intensity fighting by well-dispersed, militia-like units in massive numbers. It would have to be fought until the main enemy, the United States, was confronted and defeated.

But as Cayetano Carpio stood still and aloof, the other guerrilla factions and even elements of his own forces were evolving with the changing demands of the war on the ground.

As recently as 1980 the other groups tended to coalesce around the power and international prestige of the Popular Liberation Forces. But by mid-1982 its isolation from the rest of the guerrilla front was apparent. While the other factions coordinated their actions, the Popular Liberation Forces insisted on striking out on its own. At a crucial moment, as the rest of the rebels attempted to mount a major campaign against the March 28 election last year, Cayetano Carpio's troops did virtually nothing in their traditional areas of control.

In this context of increasing isolation and alienation, as one well- informed senior figure in the guerrilla movement now tells the story, an internal dispute was developing all last year.

It began, according to senior members of the guerrilla movement, when a high-level delegation led by Popular Liberation Forces second-in-command Anaya Montes returned from a visit to Vietnam in 1981.

Cayetano Carpio based much of his rigid dogma on his reading of the Vietnamese experience. But when Anaya Montes came back she is said to have suggested that the Vietnamese themselves had a much more flexible outlook than Cayetano Carpio would concede. Suddenly there was an ideological framework for frustrations that had been welling up for some time in the ranks.

After the debacle of the March elections last year, debate became especially pointed. As leftist sources now tell it, many of the Popular Liberation Forces field commanders wanted greater coordination with the rest of the guerrilla forces and were looking for greater flexibility in broadening the Popular Liberation Forces working political alliances.

Even though Cayetano Carpio's traditional allies, the Cubans, reportedly emphasized the need for unity and flexibility, he is said to have rejected every perceived threat to his dogmas. Anaya Montes became the voice of the new line within the faction and, as a member of the leadership of the overall guerrilla front, represented it to the rebel movement as a whole.

One participant in high-level front discussions recalled, "Ana Maria would go to a meeting and make progress, Marcial would come and we would backslide."

According to this source, Anaya Montes took the decision to join in October with the other factions in a specific, concrete proposal to consider talking with the government. Then Cayetano Carpio put impossible conditions on his participation, said this source. The rest threatened to send the proposal without him. Finally, he went along, but "he signed under pressure."

The crucial showdown for control of the organization reportedly came in January with a meeting of the Central Command, allegedly made up of more than 25 leaders.

A document that appears to record the official conclusions of that meeting and that sources on the left who do not belong to the Popular Liberation Forces have said is authentic was captured by government troops in March and, through U.S. diplomatic sources, subsequently was made available to reporters. Popular Liberation Forces spokesmen said they would neither confirm nor deny its veracity and declined to look at it.

But the document confirms much that top members of the guerrilla movement have been saying about changes in the organization's line and leadership.

Virtually every dogma Cayetano adhered to was modified or reversed. It establishes the supremacy of the Central Command over the entire organization, as opposed to the authority of any one man. The emphasis throughout is on "the real situation we are living" and the need to take into account the changes in that reality. Dialogue and negotiation are to be key elements of policy. Alliances are to be broadened to include all "nonoligarchical" segments of society.

Nowhere is "prolonged popular war" mentioned. Instead, the taking of power is seen as imminent and the strategy is planned to lead toward imminent insurrection.

The document, a clear defeat for Cayetano Carpio, was approved by more than 70 percent of the Central Command, according to leftist sources. From then on, Cayetano Carpio ceased to be more than the titular authority in the organization. The real power was with Anaya Montes.

But Rogelio A. Bazzaglia, a 28-year-old commander in charge of "external" military relations, would not give in. Described by people who know him as "a kind of political son" to Cayetano Carpio, Bazzaglia allegedly plotted the murder of Anaya Montes.

Nicaraguan Interior Minister Tomas Borge, himself an advocate of "prolonged popular war," immediately denounced the killing of Anaya Montes as a CIA plot. But according to leftist Salvadoran sources, Popular Liberation Forces commanders in El Salvador, apparently suspicious, pressed him to look more closely into the case.

On April 9 the housekeeper broke, and Bazzaglia was arrested along with three accomplices who allegedly carried out the crime. Confronted with the evidence against him, Bazzaglia is said to have admitted plotting the murder.

Yet when Cayetano Carpio, on returning from a stay in Libya to the funeral of Anaya Montes in Managua, was shown the evidence and had Bazzaglia brought before him, he refused to believe what he was told, according to Salvadoran leftist sources.

Other guerrilla leaders concluded that if Cayetano Carpio had not given the order to kill Anaya Montes then his policies had been responsible. It was apparently made clear to him that, as one leftist political leader put it, "his career, his 'line,' were liquidated."

Apparently unable to face this, according to these sources, he shot himself in Managua on April 12.

Cayetano Carpio was buried in a private ceremony, his death not announced until days later. In guerrilla literature and radio broadcasts since then there have been countless homages to "Ana Maria," but very little is said about Cayetano Carpio.

"My personal conclusion," said one of the more moderate leaders of the Salvadoran left, "is that the Salvadoran revolution has been liberated from Stalin before he could get to power, and that is wonderful."