A federal judge here yesterday ordered the Library of Congress to set up a fund that its employes can use to hire lawyers or other specialists to help them bring racial discrimination complaints against the agency.

The unusual ruling, believed to be the first of its kind in a discrimination case, arises out of a long and complex lawsuit in which a black Library of Congress employe claimed discrimination and subsequent firing because he was an outspoken critic of alleged racial discrimination in the agency.

U.S. District Judge Louis F. Oderdorfer said the employe, Joslyn N. Williams largely proved his case against the library. But he said Williams should not reap any personal benefits from his suit because he had falsely told the library he was a lawyer.

Instead, Oberdorfer ruled, the library should set up the mechanism through which other employes can receive assistance in pressing their own discrimination complaints.

Oberdorfer gave attorneys for both sides until May 31 to draw up a plan to implement his order, and suggested that they reach an agreement to cure the situation he found at the library.

Oberdorfer's ruling comes against a background of alleged racial discrimination at the library in the late 1960s and early 1970s, prompting strong complaints from Williams and the union local of which he was president. Williams also was general counsel of an organization known as the Black Employes of the Library of Congress, which also brought many complaints.

It was during a specific round of complaints about the library's employment practices that Williams' falsification of his credentials was discovered.

Williams tried to "explain away his falsehoods" and continued his public opposition to the library's alleged discriminatory employment practices, but was told that he would be fired for lying to the library. He was permitted to resign effective Aug. 11, 1972, but then unsuccessfully tried to withdraw his resignation.

Williams has since served as executive director of the union, but at the same time, Oberdorfer said," services available to employes at the library in administrative proceedings have deteriorated."

He said that despite the library's claim that Williams was fired for lying to the agency, "it would have required saintly discipline for these particular library managers not to be influenced in deciding to terminate him by hostility against his efforts to expose discrimination at the library."

Oberdorfer observed that the library officials involved in the termination "did not evidence the initiative and sensitivity about equal employment opportunity and about discrimination which other federal government officials then enforcing the civil rights laws demanded of managers of businesses, universities, state and city schools, and other local functions."

Oberdorfer did point out that new leadership at the library "has been increasingly innovative and responsive" to equal employment laws, but said he is persuaded that the library officials who dealt with Williams in the past reacted too strongly to his union involvement.

He said he was drawing on the "broad language and legislative history" of civil rights legislation to set up the library-supported fund. He called it a "unique remedy" that serves the public interest without rewarding Williams for his misconduct.

There was no immediate estimate available of the amount of money it might take to set up such a fund, how many employes it might assist, or how it would operate.