BONN, NOV. 9 -- Exactly one year after the opening of the Berlin Wall, Soviet President Mikhail Gorbachev and German Chancellor Helmut Kohl signed a treaty today giving the Soviet Union the closest ties it has ever had to a Western nation.

The treaty between Europe's richest and largest countries includes their first mutual nonaggression agreement since the Hitler-Stalin pact of 1939.

"A new vision of the world has triumphed," Gorbachev said. "The era of confrontation is over. The face of Europe and the world has changed. Our treaty is a strong and healthy child of these changes."

Kohl called the agreement "an appeal to all citizens to play their part in the process of reconciliation." Later he added, "I think we've actually done a rather good job in Bonn."

Gorbachev's return to the country whose people overwhelmingly credit him with making German reunification possible began under unusually tight security in the aftermath of the shooting that marred Wednesday's Revolution Day celebration in Moscow's Red Square.

The treaty "was until recently hardly conceivable," Gorbachev said. The improvement of relations between Germany and the Soviet Union, he said, "was accelerated by the stormy process of domestic upheaval in East Germany."

Both leaders said they view the treaty not as a threat to any other nation, but as part of the process of creating a Europe in which national borders are less important.

The two countries' roles have reversed markedly since Gorbachev's May 1989 visit to Bonn, when he hinted that the wall could fall. Gorbachev was then still the leader of the enemy East Bloc, and his revolutionary politics brought out cheering crowds of Germans anxious to end their nation's post-war role as the tripwire in the superpower stand-off.

Today, Kohl holds the reins of power, dispensing aid from the coffers of the continent's most stable economy, feeding and clothing Soviet soldiers and leading the West in setting the tone of the new relationship with an ever-more dependent Soviet Union.

Gorbachev tonight said Kohl had "showed great interest in . . . how things are going" in the reform process. "I was able to give very exhaustive replies," Gorbachev said. "But if anything was not clear, I'd be happy to try to clear it up."

The treaty brings the Germans and the Soviets together in a way that goes beyond the ties Moscow has been arranging with other Western countries.

Last month Gorbachev signed a treaty of cooperation with France, but the nonaggression portion of that document did not go nearly as far as the German agreement. The German-Soviet pact says that the two countries "will refrain from any threat or use of force which is directed against the territorial integrity or political independence of the other side." If either country is attacked, the treaty says, the other will not help the aggressor.

France rejected similar language proposed by the Soviets. The French agreement commits the two countries only to contact each other quickly if one nation's security interests are threatened. Some French diplomats, recalling the German-Soviet Rapallo treaty of 1922, which raised suspicions among the Western allies, have said today's agreement threatens to undermine the Western alliance against the Soviet threat.

Kohl's negotiators said, however, that they carefully avoided any conflict between Germany's obligations to NATO and its desire to forge a new relationship with the Soviets.

There is no new money in the treaty. "Nobody can exclude that, given the disastrous situation in the Soviet Union, they will not make further demands of Germany and the West," said a German negotiator. "But we've given them all we're going to give for now. Their credit is not very good, to say the least."

Kohl aides said the chancellor spent much of today's session with Gorbachev trying to find out who in the Soviet bureaucracy can be held responsible for the efficient use of German aid. Germans said they made it clear to Gorbachev that Western banks will not add to their Soviet aid until Moscow's economic reforms show some effect. To further confuse the picture, nearly every republic in the Soviet Union has declared its independence or sovereignty, making foreign governments uneasy about directing aid to Moscow, the union's center.

Bonn already has promised the Soviets $10 billion to support the 380,000 Soviet troops and 200,000 family members still in the former East Germany, to transport the troops home and to build housing for them in the Soviet Union.

Gorbachev, in a speech at a banquet tonight at the opulent Petersberg guest house here, urged Germans to be patient with the 600,000 Soviets who will live until late 1994 in what was East Germany.

"The euphoria at getting rid of everything connected with the East German regime . . . has given a painful, sometimes even anti-Soviet twist to relations" between the two countries, Gorbachev said. "I am convinced this is a temporary phenomenon."

But Germany did pledge today to "provide help for self-help to countries and peoples who are now laying the foundations for the economic and social recovery," Kohl said. "We Germans, who have in this century been at the forefront of so many disastrous developments, must now rise to the challenge of setting an example."

The treaty also includes assurances that the Soviets will allow the 2 million ethnic Germans in the Soviet Union to preserve their language and culture -- a step Bonn considers essential to preventing a new and massive wave of immigration as economic and political conditions in the Soviet Union continue to deteriorate.

During their two-day visit, the Gorbachevs will join Kohl and his wife for coffee and cake at the chancellor's weekend home in Oggersheim. Kohl visited the Soviet leader's home region in July.

Aides said the two leaders have finally gotten beyond the suspicion that formed in 1986 after Kohl compared Gorbachev to Nazi propaganda minister Josef Goebbels. After Kohl's trip to Stavropol in July, the chancellor said, "We learned that we had similar experiences as children, read the same books and had the same education."