The foundations of the NATO alliance are being undermined by major differences between the United States and its European allies over how to deal with the Soviet Union, West German Foreign Minister Hans-Dietrich Genscher warns in the fall issue of Foreign Affairs, released yesterday.

Genscher says the debate within the alliance began with the Carter administration's pressure for sanctions against Moscow in response to the invasion of Afghanistan in 1979 and continues through the current impasse between the Reagan administration and the Europeans over the Soviet-West European natural gas pipeline.

The debate, he says, has become poisonous rather than constructive by creating an atmosphere of mistrust about the motivations of alliance partners on each side of the Atlantic.

Genscher's public appeal to American opinion-makers for a return to alliance consensus on a "realistic" policy of detente is unusual for a foreign minister of a major ally during a period of strain within NATO. It appears to reflect the widespread fears in Western Europe, and particularly within West Germany, that matters have reached a critical stage.

"We must build on existing foundations in order to overcome the differences of opinion that still exist . . . in particular as regards the question of economic relations with the Soviet Union," Genscher says in the article. "As long as we have not succeeded in bringing the differing opinions sufficiently close together. . . , we must at any rate conduct the discussion in such a way that no damage is done to the foundations of the alliance."

Genscher has been West Germany's foreign minister for the past eight years and also is head of the small Free Democrat Party, the coalition partner of Chancellor Helmut Schmidt's Social Democrats. It is believed in Bonn that even if the current coalition government collapsed, Genscher could emerge in the same position in partnership with the Christian Democrats.

His article in Foreign Affairs argues strenuously with the Reagan administration's sanctions against European firms supplying U.S. technology to the Soviet Union for use in the natural gas pipeline to western Europe.

Rather than punishing the Soviets for imposing martial law in Poland, Genscher argues that the sanctions actually could work in the longer-term interest of the Kremlin.

"Immediate, widely-felt effects," he adds, would come only from a disruption of grain supplies from the West, the one thing Reagan has refused to do. A grain embargo imposed by the Carter administration following the Afghan invasion had failed.

"It must be borne in mind that the Soviet Union is in any case facing major economic difficulties in the 1980s. Western trade restrictions could exacerbate these difficulties only to a small extent. They would, however, afford the Soviet leaders a pretext for ascribing all the difficulties to the 'trade war' waged by the West against the Soviet fatherland," Genscher writes. "True pressure for reform in the Soviet Union and the Eastern bloc as a whole comes from within. External pressure would paradoxically reduce this internal pressure."

Similar arguments were at the core of detente politics of the 1960s and '70s, but have been replaced by recent American policy-makers, especially in the Reagan administration, with a policy of more strident confrontation with Moscow. Genscher builds a case that the United States, "suffering from the double traumas of Vietnam and Watergate," first created a problem by failing to keep its military power on a par with Moscow's -- an essential companion to a policy of detente in Genscher's view -- and then swung too far in the other direction once it realized the problem, abandoning detente altogether.

"The prerequisite for detente is equilibrium," Genscher says. "In the 1970s, however, American arms spending fell in real terms, while that of the Soviet Union continued to rise steadily. During the Angola crisis in 1975, the American Congress adopted a law making it clear to the whole world that the United States did not intend to become involved in the conflict. The Soviet Union regarded this as a carte blanche for an intervention by Cuban troops."

During this period, in effect, the West German foreign minister argues, that the U.S. policy was all detente but without a commitment to a worldwide balance of power to shore it up.

The Reagan administration now has swung completely in the other direction, ironically, he argues, just at the time when the Soviet leadership is facing a "guns or butter" squeeze on resources.

It is just such a squeeze, Genscher says, that could lead Moscow toward a policy of genuine detente, which he describes as a "readiness for dialogue, negotiations and cooperation on equal terms with the East, with the aim of keeping a check on the East-West conflict and reducing tensions."

"It is imperative today that we avoid the mistakes that led to the Second World War when the democracies, with their policy of appeasement, permitted the German Reich to gain military superiority in Europe," Genscher urges. "Equally, we must not repeat the mistake that led to the First World War, when both sides lost control over developments and, despite a balanced situation, drifted into a war that nobody wanted."