A nearly 2-year-old murder case in El Salvador is testing both the strength and the limits of U.S. influence in that country, where internal loyalties often outweigh the demands of foreign policy, and political power struggles can be deadly.

The case involves the assassination in San Salvador of Americans Michael Hammer and Mark Pearlman, consultants to El Salvador's land-reform program, and the Salvadoran head of the program, Rodolfo Viera. On Jan. 3, 1981, the three were eating dinner in a dining room of the Sheraton Hotel when they were shot dead at close range. No one claimed to have seen the killings. Although there were strong suspicions, no one claimed to have proof of who did it.

The resolution of the murder case is considered important to U.S. policy, because Congress has made continued U.S. aid to El Salvador dependent on progress in that case and in the unresolved 1980 murders of four American churchwomen. Critics charge that the Reagan administration, and the Salvadoran government it supports, have stonewalled serious action on both cases because elements of the Salvadoran military have been implicated.

There was general optimism several weeks ago when the Hammer-Pearlman-Viera killings appeared to be solved.

According to the American Institute for Free Labor Development (AIFLD), an AFL-CIO affiliate that employed Hammer and Pearlman, and that had put its own investigator on the case, two Salvadoran military officers late last month flunked FBI-administered lie-detector tests on their involvement. Earlier, two Salvadoran National Guard corporals had confessed to the killings, and said the officers ordered them to shoot the three men that evening.

Unofficially, the United States, which cooperated with AIFLD and El Salvador in the investigation, finds the evidence conclusive.

But each of these three actors in unraveling the case, according to U.S. and Salvadoran sources close to the case and knowledgeable about the two governments' policies, has strong doubts about whether even strong official pressure now being exerted by Washington will result in prosecution and conviction of the allegedly guilty parties.

Moreover, there is a concern, these sources say, that this case, and the circumstances around it, could become so unwieldy it could threaten the whole shaky structure in El Salvador, where a temporary and bitterly divided government is trying to win a war against leftist guerrillas.

"You wouldn't believe how complicated it is," said one source who, like most of the others, declined to be identified. In a general sense, "it's all tied up with the [killings of the American] nuns, and the death squads and the whole dirty business."

The biggest complication, sources said, is the fact that the case at least peripherally touches right-wing ex-Army major Roberto D'Aubuisson, former intelligence officer, alleged former plotter of coups and current head of the newly elected national assembly.

While it must now tolerate D'Aubuisson, who in 1980 was deported from the United States as an undesirable alien, Washington still finds him difficult.

Since long before last March's election, D'Aubuisson has been one of the most outspoken foes of the land reform said to be crucial for peace in El Salvador. He has significant support within the armed forces as well as among the country's wealthy elite.

D'Aubuisson's power in the country may now be second only to that of Defense Minister Jose Guillermo Garcia, who has been his chief rival for the loyalty of various factions in the military through a series of coup scares reported over the past several months.

Garcia also is expected to run against D'Aubuisson in March 1984 presidential elections.

Despite his hard-line reputation on human rights and social justice issues, Garcia is considered a reliable ally by administration sources. They say he can be counted on to push reforms and the kind of action the United States believes is necessary to win the war against the guerrillas.

The next arena in which Garcia and D'Aubuisson may square off for a power battle could be the Viera murder case.

The circumstances surrounding the assassinations, according to an internal AIFLD report completed last week and interviews with AIFLD officials and other sources, are as follows:

By December 1980, Rodolfo Viera, a former peasant leader who had administered the Salvadoran land reform program since its inception 10 months before, had informed then president Jose Napoleon Duarte of his intention to resign.

Between them, Viera and his aide Leonel Gomez had been the targets of at least eight assassination attempts, including one in which Viera was wounded.

According to Gomez, who fled El Salvador after the murders and has requested political asylum in the United States, the attacks presumably were orchestrated by rightist landowners and their allies in the military who opposed the reforms.

Hammer, a longtime AIFLD supervisor in Latin America and close adviser to the Salvadoran reform program, was so concerned about problems with the program -- including what he charged in an interview two weeks before his death were military efforts to block it -- that he came to Washington to warn the U.S. administration that the reforms were in jeopardy. In January he traveled to El Salvador to talk to Viera.

On the evening of Jan. 3, Hammer, Viera and Pearlman went to the Sheraton for dinner. According to the AIFLD report, National Guard Lt. Rodolfo Lopez Sibrian, assigned to the intelligence division, Army Capt. Eduardo Avila, and two National Guard bodyguards also showed up at the hotel.

Both Lopez Sibrian and Avila are men of some notoriety in El Salvador. Both had been arrested with D'Aubuisson in May 1980 on suspicion of coup plotting. Last September, Avila was expelled as Salvadoran military attache in Costa Rica after being charged there with "terrorist activities" including a bombing.

Avila's uncle, a ranking member of D'Aubuisson's Arena political party, is now a justice on the Salvadoran Supreme Court.

A dinner companion, rightist businessman Hans Christ, recognized the Viera party and, according to AIFLD, remarked to the others, " 'Look at that son of a bitch Viera , he has let his beard grow. I wish he were dead.' " It was then that "plans were made to carry out the assassination."

In the parking lot, the AIFLD report continues, Lopez Sibrian instructed his bodyguard to go inside and "kill" Viera, Hammer and Pearlman. Lopez Sibrian and Avila gave him and another soldier two submachine guns.

"After waiting a few moments to gather their courage, [the bodyguards] entered [the restaurant] and carried out the assassination."

According to AIFLD official Jack Heberle, all of this was discovered through "the same system used" to investigate "the nuns' case" -- detailed interviews of all low-level soldiers in the area the night of the crime.

Late last month, FBI polygraph experts tested the two officers implicated by the soldiers who had confessed. Heberle said they flunked while denying involvement in the crime. D'Aubuisson, speaking in a television appearance as head of his party, called Avila and Lopez Sibrian "good soldiers" and his friends.

Shortly thereafter, Avila disappeared and was last reported seen in Guatemala.

Lopez Sibrian was arrested. But last week, a Salvadoran judge ordered his release for "insufficient evidence" after the bodyguards, who had identified him by physical description, failed to pick him out of a lineup. The lineup, according to one official, was "a sham," since Lopez Sibrian, a redhead nicknamed el fosforito -- "the little match" -- had dyed his hair black and shaved his moustache. On the day of the hearing, Avila's uncle, the Supreme Court justice, was seated in the front row.

The U.S. Embassy in San Salvador, breaking a long official silence on the case, said it was "incredulous and dismayed." The Salvadoran attorney general immediately appealed the decision to release Lopez Sibrian. Presumably under Garcia's orders, he is now confined to barracks.

In a private letter last week to AFL-CIO President Lane Kirkland, AIFLD director William C. Doherty Jr. blamed the situation on "corruption" in El Salvador, where "no internationally recognized judicial system prevails" and unpopular verdicts may result in dead judges. "In the meantime," Doherty said, "we are simply asking that the apparently responsible parties be held until fair trial is possible."

For the United States and its allies in El Salvador, sources say, the problem is more complicated.

If Garcia uses his power to see that those implicated in the killings are prosecuted, it may be interpreted as a move against what one source called D'Aubuisson's "group" in the armed forces and elite. D'Aubuisson may be able to muster enough outrage to oust Garcia or take over the government. If Garcia is ousted, D'Aubuisson's election as president might be ensured.

To further complicate things, in a way typical of the murkiness of military matters and power struggles in El Salvador, former Viera adviser Gomez says he believes Garcia ordered the murders to get rid of the troublesome reform leader.

If Garcia does not act, these sources say, he runs the risk of seeming to back down in a power struggle or covering up.

Worse, from the U.S. point of view, would be the implication that Washington, because of the overwhelming influence it is perceived to have in El Salvador, is helping to stonewall in the case to protect members of the Salvadoran armed forces.