Douglas M. Schlachter, a key aide to former CIA agents Edwin P. Wilson and Francis E. Terpil, pleaded guilty yesterday in U.S. District Court here to charges that he conspired with Wilson and Terpil to supply explosives and train commandos for Libyan leader Muammar Qaddafi.

Schlachter, 39, who has spent the past three months in protective custody while he told law enforcement officials and congressional investigators about his activities in Libya, also pleaded guilty to violating federal laws regulating the shipment of explosives.

Wilson and Terpil were indicted first in April 1980 and again last August with Schlachter in a 1976 contract that Wilson and Terpil had to supply explosives, high technology weapons and training to the Libyan goverment. Wilson, who is living in Tripoli, and Terpil, who was last seen in Beirut, are both fugitives.

The court hearing yesterday was conducted under unusually tight security. Eleven deputy U.S. marshals were posted inside the courtroom where Schlachter entered his guilty pleas. A security detail has also been assigned to protect the chief government prosecutor, Assistant U.S. Attorney E. Lawrence Barcella Jr.

U.S. Marshal J. Jerome Bullock said yesterday that the security detail was ordered Thursday after his office obtained "information that concerned us." He declined further comment.

Schlachter, who prosecutors said supervised Wilson's Libyan operation, has consistently maintained that he believed his work in Libya was sanctioned by the U.S. government, particularly because of Wilson's long and close association with the intelligence community.

Alvin C. Askew, Schlachter's lawyer, has said that his client regularly reported to Thomas G. Clines, the now-retired head of the CIA's clandestine services division, about Wilson's activities in Libya.

Yesterday, however, Judge John H. Pratt rejected Askew's request that Clines and other agency officials, including former CIA director Stansfield Turner, be ordered to testify in court before Schlachter is sentenced.

In court papers sealed by Pratt, Schlachter contended that Turner, Clines, Clines' former supervisor, Theodore P. Schackley, and other current and former intelligence officials, as well as former Wilson employes, could back up his contention that he "had reason to believe" he was working for government agencies.

Schlachter contended in the sealed papers that he could present, through documents and testimony, "extensive mitigating circumstances" underlying his actitivies that he thought Pratt needed to know before imposing any sentence. He said that some of the 15 persons he listed as potential witnesses would not appear to testify unless ordered to do so by the court.

As a result of his guilty pleas yesterday, Schlachter faces a maximum of seven years in prison or $110,000 in fines or both. No date has been scheduled for sentencing.

The CIA has repeatedly denied allegations involving the agency in any illegal activities by Wilson, Terpil or their associates. In January, the agency said in a statement that it could find no "documentary evidence of any official relationship" between Schlachter and any current or former agency officials.

The agency has acknowledged that some agency employes provided support to Wilson and Terpil without official agency sanction and said that action was taken against those employes.

Following disclosures about Wilson and Terpil's activities, the agency adopted last month a new code of conduct, under consideration at least since last fall, which cautions employes against using information obtained from the agency in private business dealings.