Salvadoran troops have killed 21 leftist guerrillas and captured nine others belonging to the group that claimed responsibility for the June slayings of four Marines and nine other persons in San Salvador, Defense Department officials said yesterday.

But it was not clear that the raids, said to have been carried out with the help of U.S. intelligence, were in direct retaliation for the June 19 killings at a sidewalk cafe in the Salvadoran capital. Moreover, U.S. and Salvadoran officials emphasized that there was no indication that the triggermen in the attack were among those killed or captured.

Pentagon officials said the ongoing Salvadoran military campaign, which began two weeks after the cafe assault, resulted in the capture of two key leaders of the Central American Revolutionary Workers' Party (PRTC) and that 40 members of the group had been wounded.

Defense Secretary Caspar W. Weinberger disclosed the Salvadoran operations in a morning interview with the Mutual Radio Network in which he said the Salvadoran government "with our assistance has taken care of, in one way or another, taken prisoner or killed . . . a number of the people who participated in that killing."

Weinberger, who was discussing U.S. responses to terrorist attacks, did not elaborate. A Pentagon spokesman said later that Weinberger had not meant to suggest that the triggermen in the June 19 attack had been captured or killed.

Pentagon officials said the operations by Salvadoran troops specially trained and armed by the United States were assisted by U.S. intelligence, but they refused to be specific. A Salvadoran army spokesman said the raids were planned with the help of U.S. intelligence reports and documents captured from a PRTC leader in April.

Other U.S. officials played down the role of U.S. intelligence in the operation. A White House official said tactical intelligence of the kind that has been provided to the Salvadorans for some time helped locate the guerrilla organization.

Pentagon officials described the raids as a "major defeat" for the PRTC, the smallest of the rebel forces that have been battling the Salvadoran government for the past five years.

Two days after the cafe attack, a unit of the group claimed responsibility for gunning down the four off-duty, unarmed embassy guards, two American businessmen and seven other people.

Maj. Carlos Aviles, the Salvadoran army spokesman, said yesterday that military information from El Salvador appears to have been initially "misinterpreted" in Washington. Salvadoran forces have hit hard at the PRTC in recent months but have no information indicating that any of the cafe assailants have been killed or taken prisoner, Aviles said.

A Salvadoran military source said recently that the Army attacked PRTC forces along the Lempa River in San Miguel province in late June or early July. A PRTC commander named Arlene Siu may have been killed during the attacks, he said, but this has not been confirmed.

Weinberger, asked in his Mutual Radio interview whether the United States has retaliated for the cafe attack, said, "We've done a number of things that are, I think, very discouraging to future terrorist acts."

He then described the Salvadoran campaign.

President Reagan, in a solemn ceremony June 22 marking the return of the four Marines' bodies to the United States, pledged that their killers would "not evade justice on Earth any more than they can escape the judgment of God. We and the Salvadoran leaders will move any mountain and ford any river to find the jackals and bring them and their colleagues in terror to justice."

After the killings the administration announced it would seek additional military and other assistance for El Salvador, including weapons and intelligence training.

Weinberger's critics said yesterday that he may have exaggerated the importance of routine Salvadoran attacks against leftist rebels and the role of U.S. intelligence to demonstrate success in avenging the June 19 deaths and to set the stage for extra military aid for El Salvador.

A member of the Senate Intelligence Committee said, "If you press the Pentagon about what specific information we supplied the Salvadorans, they back off. They Salvadorans did it on their own. We provided certain tactical intelligence like we always do.

"Ask if we've given them any more intelligence than we were giving them six months ago, that a certain group was operating in a certain quadrant," he said. "Ask if anything they did was at U.S. request." The answer is no, he said.

Rep. Dave McCurdy (D-Okla.), a member of the House Permanent Select Committee on Intelligence, said the PRTC "has been on their Salvadoran government's hit list anyway."

The group was a target of the Salvadoran army even before about 10 uniformed gunmen executed the Marines and the others in crisp, underworld-style at the cafe.

The same PRTC urban commando unit that claimed responsibility for the attack reportedly ambushed a Salvadoran army patrol in 1984 and national police vehicles twice this year, using automatic rifles, hand grenades and rocket-propelled grenades.

But Salvadoran officers do not appear to attach particular importance to the group. The army's chief of staff, Gen. Adolfo Blandon, gave an hour-long briefing to reporters yesterday without mentioning the group or the military's attacks against it.

In a terse statement responding to reporters' questions, the U.S. Embassy in San Salvador said: "We have not seen the context of Secretary Weinberger's remarks. But we understand his remarks dealt with matters of U.S. intelligence, upon which we do not comment as a matter of policy."