Soviet dissident Anatoly Scharansky was freed today from nine years in captivity as part of an East-West prisoner swap that culminated months of secret bartering and a global crusade by a wife who had not seen him since the day after their wedding in 1974.

The 38-year-old computer programmer, who became a symbol for Soviet human rights activists and fellow Jews seeking to emigrate to Israel, was released at 11 a.m. local time to the custody of U.S. and West German officials at the Glienicke Bridge checkpoint dividing West Berlin from East Germany.

About 30 minutes after Scharansky crossed the snow-dusted steel span, eight accused or convicted spies -- five detained in the West and three in the East -- were exchanged to complete one of the most highly publicized spy trades in recent years.

The United States insisted upon the distinction in timing to underscore its contention that Scharansky never served as a western agent. He was arrested in 1977 on charges of working for the Central Intelligence Agency and sentenced later to 13 years in prison.

Looking fit and exhilarated despite his arduous years of detention in a labor camp, Scharansky strolled briskly in the company of U.S. Ambassador to Bonn Richard R. Burt to a waiting limousine. His short frame was draped in a bulky overcoat. He showed no sign of ill health as he smiled and waved while being driven to Tempelhof military airfield.

There Scharansky was given a basket of fruit and wine by Burt's wife, Gahl, according to U.S. officials, who said he quickly opened the basket and began eating the strawberries, marveling at their size and freshness.

After changing aircraft because of technical problems caused by frozen brakes, Scharansky was flown out of Berlin aboard a U.S. military plane to Frankfurt to be reunited with his wife Avital, who emigrated to Israel in 1974 and has conducted a tireless campaign to win his freedom.

The couple later continued their journey to Tel Aviv, where Anatoly responded in halting Hebrew to an emotional welcome.

Scharansky told U.S. officials he was removed from the labor camp a month ago and fed well before his release. He was quoted as saying that when Soviet authorities told him the other day he was being exchanged as a spy, he laughed profusely out of delight and incredulity over his fate.

The exchange, witnessed by hundreds of journalists who had staked out the bridge for more than a week, was brokered largely by the U.S. embassies in Bonn and East Berlin and Wolfgang Vogel, an East German lawyer with close ties to the communist leadership in his own country and the Soviet Union.

An agreement on a prisoner swap involving Scharansky was nearly concluded last fall, prior to the Soviet-U.S. summit meeting at Geneva in November, but Moscow backed out inexplicably at the last moment, according to informed sources close to the negotiations.

After the summit, Vogel contacted U.S. and West German officials and said the Soviet Union no longer held any reservations about an exchange and was prepared to expedite negotiations. U.S. and West German officials said they believe the Kremlin wanted to resolve the case, which had evolved into an embarrassing symbol of human rights abuses, before the Soviet Communist Party congress Feb. 25.

The Soviet leadership's desire to defuse world opinion over Scharansky's fate may also have helped to temper demands for several highly sought agents still detained in West Germany. Bonn agreed to turn over three Soviet Bloc agents in the deal, but they were regarded as "prize catches," according to West German officials.

President Reagan expressed his warm appreciation to West German Chancellor Helmut Kohl for Bonn's "substantial contribution" in securing Scharansky's release. Sources close to Kohl said he was motivated not only to resolve an important human rights issue, but to enhance relations between Moscow and Washington in the hope that this will improve the two Germanys' ties.

The final arrangements were nearly scuttled when news of the impending exchange appeared 10 days ago in the West German mass-circulation daily Bild. But U.S. officials said they rebuffed calls for a change of venue and other last-minute alterations, insisting that the exchange should take place on the agreed date before the press.

The separation of the two release ceremonies was considered a diplomatic victory for the United States, which adamantly refused to link Scharansky in any way with the other eight convicted or accused spies. Washington has always denounced Moscow's imprisonment of Scharansky as unjust punishment for his human rights activities.

Both Reagan and Kohl, in a joint statement, welcomed his release as "a prisoner of conscience."

"Anatoly Scharansky was never an agent of any kind of the U.S. government, despite the trumped-up evidence which the Soviet Union presented against him," Ed Harper, a spokesman for the U.S. Mission in Berlin, told reporters at the bridge. "The terms of his release in no way change that basic fact," he added.

Once Scharansky departed from the drab green Glienicke Bridge, vans and buses maneuvered into position to conclude the swap of the eight alleged spies. Numerous East-West swaps have taken place at the bridge, including the exchange in 1962 of downed U2 pilot Francis Gary Powers for the Soviet master spy Rudolf Abel.

At Potsdam on the eastern side of the bridge, two Germans and a Czechoslovak were escorted to the white dividing line in the middle of the span to board a waiting bus for the trip to the West.

Bonn government officials said the three men were: Wolf Georg Frohn, 41, an East German; Jaroslav Javorsky, 38, a Czechoslovak, and Dietrich Nistroy, 50, a West German.

The five released by the West included two jailed in the United States: Karl F. Koecher, 52, a Czechoslovak, and his wife Hana.

West Germany released three alleged agents: Soviet Yevgeny Zemlyakov, Pole Jerzy Kaczmarek, and East German Detlef Sharfenorth.