Federal agents arrested fugitive ex-CIA agent Edwin P. Wilson as he stepped from a plane in New York City yesterday, closing what one law enforcement official called "a spider's web" around the man charged with aiding terrorists worldwide.

Looking disheveled but stoic after a night of travel from Europe and the Dominican Republic, Wilson was ordered held in lieu of $20 million bond at government request, an amount the judge said was unprecedented.

Wilson, 53, had been a fugitive since April, 1980, when he and Francis E. Terpil, another former CIA agent, were indicted in Washington on charges of providing Libyan dictator Muammar Qaddafi with explosives, terrorist training and assassination services.

Terpil remains at large, and was last reported living in Beirut. The two allegedly used their CIA connections to set up an international arms business in the early 1970s, supplying terrorists and government clients with explosives, terrorist training and digital timers built to explode a year or more after placement.

They reportedly recruited former Green Beret soldiers to do their training in Libya, and Wilson was called the boss of former Green Beret Eugene Tafoya, who was charged with the attempted murder of a Libyan student in Colorado last year.

Wilson had been living in a luxurious villa outside Tripoli as an adviser to Qaddafi for the past year, and was tricked into leaving the country by "a large covert operation" that "went absolutely perfectly," according to a knowledgeable law enforcement official here.

"He thought he was leaving permanently," the official said. "He was led to believe he was going to a safe haven, and in fact he was being led into a spider's web." Justice Department spokesman John Russell confirmed that account.

Attorney General William French Smith announced the arrest, calling Wilson "a major fugitive from justice" and praising the U.S. Marshals Service for "an outstanding investigative effort."

Wilson left Libya Monday, traveling on a false Irish passport under the name Philip McCormick, the Justice Department said. He made two stops in Europe before arriving around 5 a.m. yesterday in the Dominican Republic, where airport authorities had been warned that he was coming.

"He was under surveillance the whole time," the law enforcement official said, adding that to name the European countries would endanger agents there.

Jeff Harris, a deputy associate attorney general, said Dominican authorities told Wilson in customs that his papers were insufficient to enter the country.

They held him in a secure area, then put him on a nonstop, regularly scheduled flight to New York, telling him his destination just five minutes before the plane took off.

"He told the Dominicans he didn't have a visa for the United States," Harris said. "They told him he didn't have to worry about that."

Two federal agents were on the plane by pre-arrangement, but Wilson was not arrested until the plane landed at Kennedy International Airport in New York, Smith said.

At the arraignment in U.S. District Court in Brooklyn, the 6-foot-4 Wilson stood impassively as federal prosecutor E. Lawrence Barcella described him as a "very intelligent and very resourceful" man with "tremendous access to wealth" and 20 years' experience in intelligence work.

Bail of $500,000 set at the time of indictment would be inadequate, Barcella said, given Wilson's 2,400-acre farm near Upperville in Fauquier County, Va., and two million-dollar properties in England.

The prosecutor revealed for the first time that he had spoken with Wilson once in person and at other times on the telephone in the past two years.

The law enforcement source said that the Justice Department would consider reducing charges against Wilson, "as is done in any case," in return for useful information, provided it is well-corroborated. "He surely knows a lot," the source said.

Douglas M. Schlachter Sr., a third ex-agent charged in 1980, surrendered last year, offering cooperation. He pleaded guilty in February to a reduced conspiracy charge.

The House Intelligence Committee is investigating possible links between Wilson and Terpil and CIA agents who might have had contact with them in the 1970s.

The CIA repeatedly has denied any official involvement with the men's operation, disciplining two employes it said had dealt secretly with the pair. The CIA also set up a code of conduct to keep former agents from using their CIA experience for private gain.

A bail hearing and a proceeding to remove Wilson to Washington are set for today. CAPTION: Picture, EDWIN P. WILSON . . . bail set at $20 million.