Gen. Reinhard Gehlen, 77, Hitler's chief anti-Soviet spy in World War II who later became a Soviet expert for the United States and the first head of West Germany's secret service, died Friday at his home near Munich.

The death was reported by relatives, according to Reuter, which said he had cancer of the prostate gland and had been released from a hospital three months ago.

Gen. Gehlen was head of West Germany's "Bundesnachrichtendienst" (BND) from the time the secret service was officially recognized in 1956 until he retired in 1968.

He had set up its forerunner, known as the "Gehlen Organization," at the request of the U.S. occupation forces in Europe after World War II.

It has been estimated that he and the thousands whom he employed in his counterespionage organization provided this country's Central Intelligence Agency and the Pentagon with 70 percent of its intelligence on the U.S.S.R. and Eastern Europe.

Gen. Gehlen was born at Erfurt (now in East Germany), the son of a publishing house director. He joined the German army in 1920 and served as a cavalry and artillery officer. Following Hitler's rise to power, Gen. Gehlen was given secret service training and became an officer on the general staff. He was considered brilliant at desk work.

He continued to move up as he participated in the invasion of Poland and the sweep across France. Then in 1942 he became head of Nazi intelligence for the Eastern Front.

But Gen. Gehlen ran into head-on opposition from Hitler when he organized a Russian Army of Liberation from among anti-Communist prisoners of war and partisans who had been captured in the German invasion of the U.S.S.R. He soon fell into disfavor.

He remained loyal, however, to Hitler until he began to see the approach of the end of the war. He saved his massive secret service files on the Russians by hiding them in steel cases in Bavaria.

After he surrendered to the American forces, he negotiated a deal with this country to establish a secret intelligence service for the occupation forces.

It had been apparent to the Americans that they were totally unprepared when it came to intelligence about the Soviets. Gen. Gehlen was given autonomous command over a personally chosen German staff to organize cold-war espionage in the Soviet zone for this country.

It is estimated that he hired between 4,000 and 2,000 people to work for him. Many of them were ex-Nazis. He was financed with millions of U.S. dollars.

West German chancellor Konrad Adenauer reportedly had much confidence in Gen. Gehlen's skills, and he was given comparatively free rein after his organization became official.

But West Germany newspapers criticized the mystery with which the so-called "faceless general" operated. In 1961, he suffered a setback when it was discovered that his chief of counterintelligence, Heinz Felfe, was a Soviet double agent.

Gen. Gehlen's influence and reputation further waned after the death of Adenauer in 1967. His critics attacked his strong anti-Soviet views as outdated, and he retired a year later.

Gen. Gehlen married the former Herta von Seydlitz-kurzbach and they had four children.

Since retirement, he had lived near Starnberg Lake in Bavaria and spent most of his time involved with the Evangelical (Protestant) Church. CAPTION: Picture, REINHARD GEHLEN