SAN SALVADOR, OCT. 28 -- In a controversial move designed to promote national reconciliation, El Salvador's legislature has passed a broad amnesty law that applies to perpetrators of military massacres and death squad killings as well as to Marxist guerrillas.

The law, proposed by the government of President Jose Napoleon Duarte to show compliance with a Central American peace plan, was passed 45 to 0 last night by the Legislative Assembly. The vote was boycotted by 15 right-wing opposition and independent deputies on the grounds that the bill was not tough enough on leftist guerrillas.

In last-minute changes to the bill, an exception to the amnesty was made in the case of Archbishop Oscar Romero, who was assassinated by a suspected death squad gunman in March 1980. Those responsible for his death, if they are apprehended, will not be eligible for amnesty, the law says.

It also declared ineligible the perpetrators of any offenses committed after Oct. 22, a provision that excludes the killers of Herbert Anaya, the president of the leftist Human Rights Commission of El Salvador. He was shot Monday by two unidentified gunmen in an incident that raised fears of renewed death squad activity related to this country's eight-year civil war.

The amnesty law has come under attack from leftist and human rights groups because it defines political offenses so broadly as to include practically all crimes connected to the civil war except kidnaping, extortion and drug trafficking. Specifically included in the amnesty are the perpetrators of "common crimes" in which the number of participants is "no smaller than 20." Human rights activists say this alone tends to absolve members of the military and security forces who massacred people in sweeps or death squad operations.

Legislative Assembly sources acknowledged that among those apparently eligible for amnesty would be the right-wing National Guardsmen who killed four American churchwomen in December 1980 and two U.S. labor advisers in January 1981, and the leftist guerrillas who gunned down 13 persons, including four U.S. marines, at a sidewalk cafe in June 1985.

In a news conference tonight, Duarte said he believed that the killing of the four U.S. churchwomen was a "common crime" and that five guardsmen jailed for it would not be freed under the amnesty. But he acknowledged that amnesty decisions in this and other cases now would be up to the Salvadoran judicial system.

Speaking shortly after his return from a trip abroad, Duarte also said he deplored the murder of Anaya, but he accused leftist groups of "trying to create terror" by parading around the capital with Anaya's coffin. Leftist demonstrators kept the casket in front of the U.S. Embassy last night during a vigil and carried it through the streets again today in sweltering heat during a march that ended in a rock-throwing incident near military headquarters. Burial is planned for Friday.

According to a U.S. Embassy spokesman here, the State Department said that "we understand and respect President Duarte's desire to offer the broadest possible amnesty in a spirit of national reconciliation," but that "those responsible on both the right and the left for terrorist acts or crimes against U.S. citizens should not be allowed to escape justice."

Atilio Castro Salazar, a legal adviser to the Legislative Assembly, said the law is to take effect by Nov. 5, and prisoners who want to apply for amnesty must have their eligibility decided by a judge. Castro said guerrillas fighting for the Marxist-led Farabundo Marti National Liberation Front will have 15 days from the effective date of the law to appear before civil or military authorities and "state their desire to renounce violence and accept amnesty."

Armando Calderon Sol, a deputy of the right-wing Arena party, said his group objected to the absence in the law of explicit requirements for guerrillas to pledge allegiance to "the legal system and the democratic process."