BERLIN (AP) _ For years, Hans-Dietrich Genscher worked for better East-West relations, seeking to heal the postwar divisions of Europe and unify the two Germanys.

He was at the vanguard of those who took former Soviet President Mikhail S. Gorbachev at his word. That trust, and German insistence on reaching out to Moscow, hastened the end of the Cold War.

Often dodging the ire of critics at home and abroad, Genscher never lost sight of a unified Europe free of ideological barriers.

Genscher, the longest-serving foreign minister in the West, announced today that he will step down May 17 after 18 years in office. At age 65, he is a leader of the centrist Free Democrats, junior partner in Chancellor Helmut Kohl's coalition government.

In 1982, Genscher played a kingmaker role by leading his party out of a governing coalition with then-Chancellor Helmut Schmidt, a Social Democrat, to support Kohl. Since then, Kohl has relied on the Free Democrats to deliver enough votes to keep his parliamentary majority.

The affable foreign minister, one of Germany's best-known politicians, often angered the Reagan administration by insisting on cooperation with Gorbachev.

Genscher has also been in the forefront of enlisting help for the former Soviet Union, at times upbraiding the United States and other countries for not doing enough to help save the West's former enemy.

Last month's decision by the United States and other wealthy nations to start comprehensive assistance for the Russians was a personal success for Genscher.

Genscher was at the center of a North Atlantic Treaty Organization dispute over short-range nuclear weapons in 1989 that caused a deep rift between Washington and Bonn over the alliance's nuclear defense policy.

Genscher's insistence on offering talks with the Warsaw Pact to reduce short-range nuclear weapons eventually won endorsement by NATO during their 1989 summit, after the talks were linked to a conventional arms accord.

Genscher has since improved ties with Washington, and reportedly gets along well with U.S. Secretary of State James A. Baker III.

The German foreign minister last year raised some eyebrows with the way Germany won European Community recognition of Croatia. Genscher had hinted Germany would take the step by itself, forcing the EC to act.

The United States at the time advised against recognizing Croatia, saying that could intensify the fighting.

Genscher was born in Reideburg, near the eastern German city of Halle, on March 21, 1927.

Genscher was a soldier in the regular German army during World War II when he was captured by the Americans in 1945, was a prisoner of war in Britain and was returned to the Soviet-occupied sector of his homeland.

He studied law at Leipzig University but grew disenchanted with the new Socialist state, so he went to the West in 1952 and joined the small Free Democratic Party.

With the advent of Gorbachev's reform efforts and Bonn's desire to play a greater role in European events, Genscher became a driving force in German foreign policy.

Noting Germans brought about the world war that left the continent divided into two political blocs, Genscher often observed with a note of contrition that ''Europe is our fate.''

He also made it clear that he aimed for a dismantling of the divisions of Europe, in particular the concrete and barbed-wire border that divided East and West Germany until two years ago.

In 1989, Genscher told Parliament his responsibility for guiding German policy ''does not end at the border running through the middle of Germany. This obligation includes my home, the city in which I was born.''

Genscher has long had health problems, including heart trouble and a bout with tuberculosis. He was hospitalized in 1989 for surgery to correct a urinary tract problem, but quickly went back to working 16 hours a day.

Referring to Genscher's heavy travel schedule, then-Soviet Foreign Minister Eduard Shevardnadze once quipped that whenever two airliners pass each over the Atlantic, ''Genscher is on both of them.''