U.S. District Court Judge Gerhard Gesell yesterday ordered the Justice Department to begin a preliminary investigation into possible government misconduct in failing to prevent an attack by Ku Klux Klan members and Nazis on communist demonstrators at a 1979 "death to the Klan" rally in Greensboro, N.C.

Five members of the Communist Workers Party were killed moments before the march was to begin, when armed members of the Klan and the American Nazi Party arrived and shooting began. Six other protesters and a televsion cameraman were injured.

Gesell said plantiffs had furnished enough information to trigger an investigation into the incident to determine whether a special prosecutor should be named under the Ethics in Government Act. The act provides for a court-appointed prosecutor, at the discretion of the attorney general, to investigate government officials for possible criminal wrongdoing.

Six present and former Klan members and three members of the American Nazi Party were indicted by the Justice Department last month for their role in the Greensboro incident.

Following the attack, a number of victims and relatives filed a lawsuit to force the Justice Department to look into possible involvement by undercover agents of the FBI or the Federal Bureau of Alcohol, Tobacco and Firearms.

Danny Sheehan, chief counsel for the Greensboro Civil Rights Litigation Fund which brought the suit, called yesterday's ruling a "major defeat for the Justice Department. . . . There's never been any federal court order ever commanding an attorney general to undertake a special investigation."

Sheehan had charged that two BATF agents had infiltrated the American Nazi Party and knew of plans to kill the demonstrators. He also charged that one of the Klan members indicted last month was an FBI informer and had also given federal agents information about the potential for violence at the march. In addition, he had charged that federal agents may have helped plan the incident.

The plaintiffs have charged that Justice Department officials should have known about the possibility of violence and acted to stop it. But the Justice Department denied any liability and asked Gesell to summarily deny the petition.

Gesell, who gave Justice 90 days to complete the investigation, did not go as far as the plaintiffs wanted. They had asked him to name a special prosecutor.

But he did find that there was sufficient evidence to have triggered a preliminary investigation by Justice.

"The attorney general William French Smith was advised as to the disruption of the parade at Greensboro in 1979 and the attendant violence; he was advised that the FBI and BATF were in some degree of contact with some participants before the events, and the contentions of the plaintiffs as to the suspected existence of a conspiracy which should have been known to the attorney general and the director of the FBI were fully outlined in a pleading submitted to him Smith ," Gesell said.

"Throughout this long period since the incident the attorney general has failed to undertake or complete the preliminary investigation . . . ," he said.

But Gesell added that in his review of the case he found "that the claims of plaintiffs as to the involvement of the attorney general and the director of the FBI in a conspiracy are based merely on inferences unsupported by any concrete facts."

John Russell, a spokesman for the Justice Department, said there would be no comment on the ruling.