Back in the mid-1970s, Theodore G. Shackley, then the No. 2 man in the Central Intelligence Agency's clandestine service, was busy cultivating one of the agency's former operatives, Edwin P. Wilson, as a back-channel intelligence source to provide information to the CIA from his overseas business contacts, particularly in the Mideast.

Wilson later was accused of supplying explosives, weapons and training to Libyan terrorists and of plotting an assassination in 1976 on behalf of radical Libyan dictator Col. Muammar Qaddafi. Now, Shackley, who is retired from the CIA, is trying to put distance between himself and Wilson. He has told federal investigators that at the time he had no knowledge of what Wilson was up to in Libya, but when he found out he and other top agency officials promptly reported it to the FBI.

The expanding investigation of Wilson and his one-time partner, Francis E. Terpil, which first surfaced in 1977, provides revealing glimpses into the netherworld of international terrorism and the merchants who supply its armaments. This world exists on the fringes of the intelligence agencies of major powers and many of its inhabitants--former intelligence agents themselves--engage, federal officials say, in illegal technological espionage and export.

The Wilson-Terpil case has repeatedly raised the question of how much and how soon the CIA knew about their Libyan and other operations in support of terrorism. It also raises questions about what the CIA has done and is doing to detect and discourage such unofficial, free-lance operations.

It not uncommon for the CIA to attempt to debrief American businessmen, journalists and other travelers abroad as sources of information. The relationship between Shackley and Wilson, however, is considerably deeper and more complex than most.

The informal intelligence channel that Shackley maintained with Wilson, along with a longstanding friendship between the men, created the appearance of CIA approval of Wilson's alleged illegal activities. This aura of respectability enabled Wilson to convince associates and clients that his arms exports and commando training were approved by high agency officials.

Prosecutors, who obtained grand jury indictments against Wilson in 1980, may seek to broaden their indictment this month. They say that Shackley is not a target of the ongoing grand jury investigation. The federal officials have also concluded "absolutely" that the CIA as an institution did not know about, condone or officially sanction the alleged illegal activities.

Wilson has denied wrongdoing and lives as a fugitive in the Libyan capital of Tripoli.

The conclusions reached by the federal prosecutors about the CIA's role and the relationship between Shackley and Wilson provide the best explanation to date of the CIA's knowledge of and response to the alleged illegal activities of its former agents in Libya.

The relationship between the two men was both social and professional. It extended from arrangments for Shackley's daughter to keep a horse at Wilson's 2,400-acre Fauquier County farm to meetings at Shackley's home and other locations where Wilson provided a steady stream of intelligence picked up from worldwide business dealings. Wilson's wife shopped for antiques with Shackley's wife; the Shackleys were entertained at the Wilson farm and Wilson often stopped at Shackley's to visit with his former CIA colleague and occasionally brought along knowledgeable merchants engaged in international arms or equipment sales.

Shackley said in an interview that agency rules prohibit him from commenting on anything relating to his CIA career. He acknowledged, however, that he knew Wilson and sought him out as a contact because "he knew a lot."

Shackley has told federal prosecutors that he considered it vital to his job as a senior official in the agency's covert operations division to develop independent contacts among businessmen, journalists and diplomats engaged in international travel and commerce. Wilson's network of business contacts and foreign government procurement officials provided Shackley with important inside information from Egypt, Iran, Turkey and perhaps Libya.

Such debriefings are usually handled by relatively low-level officials in the agency's Domestic Collection Division.

In contrast, Shackley's intelligence-gathering relationship with Wilson was withheld from President Carter's director of central intelligence, Adm. Stansfield Turner, when he investigated Wilson's contact with CIA agents and officials in 1977, according to a knowledgeable source.

Shackley contends that he fully reported his relationship with Wilson and that he was a victim of Wilson's manipulation, according to one source. Shackley thinks that his contact with Wilson was consistent with his contacts with a number of people outside the agency whom he considered knowledgeable about foreign affairs, the source said.

In this sense, Shackley "collected" friends with non-CIA perspectives so he wouldn't become a "captive of the system," the source added. Shackley denies, the source said, that he was trying to run a "hip pocket" intelligence operation through Wilson and says that Wilson lied to him about his activities in Libya.

Shackley, who retired from the CIA in 1979, worked for a time as a consultant to several international brokerage firms funded or organized with Wilson's assistance. Shackley believes this was entirely proper, because his close friend and former CIA colleague Thomas G. Clines, not Wilson, actually hired him. Shackley continues to work closely with the Wilson-backed firms operated by Clines out of a common suite of offices in Rosslyn.

Federal officials have investigated Shackley's role in the Wilson matter. They have determined that early in September, 1976, when he and other agency officials learned from Wilson partner Kevin P. Mulcahy that the focus of Wilson's Libyan trade was the export of terrorist know-how and instruments to Qaddafi, they promptly notified the FBI and the Justice Department.

Two weeks later, on Sept. 19, 1976, Shackley learned from Clines, a training supervisor in the clandestine service at the time, that three Cubans had allegedly been recruited by Wilson to assassinate a dissident Libyan living in Egypt. Again, the FBI was promptly notified.

On the basis of these reports and other evidence made available to the Justice Department by the agency, prosecutors reached their conclusion that the CIA did not condone or officially sanction Wilson's alleged illegal activities.

Shackley has told federal agents that while he received some intelligence information from Wilson about various Mideastern countries, Wilson lied to him and others connected with the CIA about the true purpose of the Libyan project, calling it a straightforward contract to clear old mines from harbors and desert territories. After Wilson's true activities were reported in September, 1976, Shackley disassociated himself from Wilson for several years.

The principal focus of the three-year investigation has been the activities of Wilson, Terpil and California explosives manufacturer Jerome S. Brower. Brower admitted that he was part of a conspiracy, beginning in mid-1976, to supply Qaddafi with a wide assortment of terrorist tools, including high explosives, electronic timers for bombs, sensitive night vision equipment and commando training programs staffed by off-duty and former U.S. Green Berets.

The Wilson-Terpil case first came to public attention in April, 1977, in several Washington Post articles, but the investigation languished for nearly 14 months while one office in the Justice Department mulled whether Wilson and Terpil had violated foreign agents registration laws and concluded they had not. Meanwhile, thousands of pounds of explosives and high-technology weapons and support systems continued to flow to Libya.

When the indictments were returned in April, 1980, the grand jury returned charges that Wilson and Terpil were illegal agents of Libya.

One of the most frustrating roadblocks, according to federal prosecutors, was identifying and finding the intended target of the $1 million assassination contract allegedly engineered by Wilson on behalf of Qaddafi. At the time of the assassination conspiracy, U.S. and Egyp-tian relations were still frayed in the aftermath of the 1973 Mideast war. Federal investigators spent months apparently working through back channels in the diplomatic community to first determine the correct name of the target, Libyan dissident Umar Abdullah Muhayshi, and then to locate him.

Then began the long process of finding evidence to show that the alleged murder conspiracy occurred in the District. They subsequently obtained statements from the Cubans, telephone records from D.C. offices and a $30,000 check drawn on the Middleburg Bank by Wilson to pay the Cubans' expenses.

Among other things, the 1980 indictments outlined the manufacture of up to 50,000 digital timers--designed to explode a year or more after concealment--assembled by college students and others in a collection of makeshift basement laboratories in the Washington area. Their assembly was supervised by former CIA technical engineer Edward Walsh, whose job was to build a total of 300,000 explosive timers for Qadaffi.

The prototypes for these timers were constructed from common components available at Radio Shack. At least one active-duty CIA agent at the time, William Weisenburger, was fired for having assisted in building the first 10 timers. Walsh was not indicted by the grand jury.

But after a 28-month investigation that led to the 1980 grand jury action, federal prosecutors discovered evidence of a more extensive conspiracy indicating that several technological fields were tapped to further Qaddafi's terrorist capabilities. Some of the individuals involved in these transactions are cooperating with federal authorities. Others may not be culpable because they were operating under the "cover story," which characterized their work as part of a mine-clearing effort.

Two of the transactions and activities focused on by the grand jury are::

The shipment of 20 tons of C-4 plastic explosive that were assembled from three locations in the U.S. and Canada in the summer of 1977 and shipped to Libya aboard private charter jets. This shipment was discovered after the original indictment. Confirmation of the shipment was elicited from Brower during a plea-bargaining session when prosecutors pretended to know about more than a few small shipments of high explosives to Libya in 1976. In fact, the federal officials did not know of the later shipment. Brower admitted his role in the overall conspiracy, pleaded guilty and served a short jail sentence in 1980.

The export of dozens of highly sophisticated night vision surveillance cameras and rifle scopes manufactured by a Vienna, Va., firm, Applied Systems Inc., and a Texas firm, Varo Inc., and illegally routed by unidentified businessmen to Libya in a manner designed to evade detection by munitions and technology control officials of the State Department. Federal investigators said that one scheme used was to ship separate packages of night vision components abroad for reassembly in a hideaway factory, possibly in the British Isles, for final shipment to Libya.

Applied Systems officials declined to comment, but a Varo executive, Samuel T. Yanagisawa, said federal officials have not faulted his firm for any sales of night vision equipment. He said his firm sold a number of "image intensifier tubes," the key component of night vision gear, to Applied Systems. He said Varo had no control over the tubes after the sale. And, the Varo official said, the tubes were sold with a specific prohibition in the contract that they not be exported without State Department approval.

Additional details have emerged in the later stages of the federal investigation that provide a rare glimpse into the murky underworld of international politics and intelligence warfare.

For instance, the three Cubans Wilson allegedly approached to carry out Qaddafi's contract assassination of Muhayshi were all involved in the CIA's 1961 Bay of Pigs invasion. Wilson himself as a young agent was in Miami at the time and later worked for the CIA supersecret Cuban destabilization program code named JM WAVE.

The three Cubans, one of them an active CIA agent, Rafael Quintero, met with Wilson in a Geneva hotel on Sept. 15, 1976, for final instructions relating to the "hit." Wilson led them to believe that the assassination was sanctioned by the CIA, they told investigators.

When the Cubans learned the identity of the target, they became angered that Wilson was proposing that they assist Qaddafi, whom they considered a radical communist. A brother of one of the Cubans was incarcerated at the time in a Cuban jail for opposing the communist regime of Fidel Castro.

Four days later, Quintero and his colleagues, Rafael and Raul Villaverde of Miami, decided to complain to the CIA. Quintero telephoned Clines, one of Shackley's subordinates in the covert operations division and, incidentally, Quintero's "control officer" during the Bay of Pigs invasion.

Clines immediately reported Quintero's call to Shackley, who then reported the assassination plot to the agency's top officials. In the meantime, CIA records made available to the Justice Department reflect that Clines told Quintero that the alleged murder plans of Qaddafi and Wilson had no sanction from the CIA. Within two days, CIA officials reported Quintero's story to the FBI and made Quintero available to Justice Department officials for detailed briefings on his contacts with Wilson.

This response by Shackley, Clines and other top officials of the CIA was a key factor in the determination by federal investigators that the agency did not condone, protect or acquiesce in Wilson's alleged activities.

Wilson, and to a lesser extent the man who introduced him to Libya, Terpil, at one time cut high profiles in Washington and rubbed elbows with powerful members of Congress and administration officials. Today, both men are fugitives.

Wilson is living in Tripoli under the code name "Angus," for the cattle he once raised in the Virginia hunt country. He continues to import equipment and technology for Libya, where no business activity is conducted without Qaddafi's blessing. Terpil, who separately supplied the terrorist regime of Uganda's deposed dictator Idi Amin beginning in 1977, is living in Beirut.

In the spring of 1976, Wilson was scrambling for income to replace plentiful Navy contracts his businesses had enjoyed from work on an intelligence effort aimed at Soviet naval capabilities. He drew on the agency's expertise and roster of current and former agents to fulfill the terms of his Libyan contract. He set up a new company with Terpil and former CIA agent Kevin Mulcahy called Inter-Technology Inc. to serve as the corporate funnel from the U.S. to Libya.

As Wilson recruited experts to help him, he conveyed to them in various ways that his activities were either being done under contract to the CIA or had official agency recognition. Wilson's close relationship with Shackley was often cited by Wilson to potential recruits and suppliers.

One of those recruits, an active-duty CIA agent stationed at the time in Indonesia, was Patry E. Loomis, who was later fired from the agency for his contacts with Wilson. "When I was introduced to Wilson in Indonesia in 1975 the one thing I was told was that he was a good friend of Shackley's," Loomis said in a recent interview. Loomis, who served under Shackley in Vietnam and held him in high regard, said he concluded that contact with Wilson was authorized at the highest levels of the clandestine service.

On one return trip to the United States in the summer of 1976, Loomis accompanied Wilson to a business meeting at the office of Applied Systems Inc., the manufacturer of sensitive night vision equipment. Loomis said he went along as part of his "cover" as an aircraft and high-technology sales representative for American aerospace firms in Indonesia.

The purpose of the meeting was to win the sales representation agreement for the company's product line. Wilson asked Loomis to pose as someone who would represent the company's night vision products in the Far East. Loomis said he went along believing the meeting to be consistent with his cover.

Loomis learned much later that Wilson had told the Applied Systems officials that Loomis was an active CIA official in an effort to make Wilson's representation offer more attractive because of the prospect of government contracts or goodwill.

Less than a year later, Adm. Turner responded to press accounts about Wilson's activities by combing the agency's files to determine all agency employes who had had contacts with Wilson. Within two weeks, Turner fired Loomis, who had introduced Wilson to Indonesian military officials in 1975. Turner also fired Weisenburger, the CIA agent who assisted in construction of 10 prototype expolosive timers for Wilson's Libyan contract in the summer of 1976.

When Turner questioned Shackley, Shackley maintained that he had only a social relationship with Wilson. Shackley did not tell his superior that he had collected intelligence information from Wilson a number of times during the summer of 1976, according to a knowledgeable source. Shackley reportedly disputes this.

Wilson also maintained business relationships with at least one high-level active-duty CIA official. Shackley's close friend and employer for a time after Shackley's retirement, Clines, reportedly participated in real estate ventures with Wilson while still in the agency. Prior to Clines' retirement in 1978, Wilson set up and funded an oil well drilling supply company in Clines' name, called API Distributors Inc. Moreover, Wilson had his corporate lawyers help Clines set up another company, EATSCO, after he retired. The company, whose acronym stands for Egyptian American Transport and Services Co., holds the exclusive concession to ship American goods to Egypt and is in a suite of offices at 1911 N. Fort Myer Drive in Arlington shared by API Distributors Inc.

Today, Shackley runs his own firm, Research Associates International Ltd., which shares office space with the Clines-Wilson companies. While Shackley's one-time formal consultant relationship with those firms reportedly has ended, he and Clines still work together informally on business deals.

Shackley sees nothing incongruous about his current affiliation with Wilson-backed enterprises, even though Shackley feels he was manipulated and used by his former colleague, one source said. "I guess," the source said, Shackley doesn't "see it in those terms."