MIKHAIL Gorbachev's invitation of South Korean President Roh Tae Woo to San Francisco dramatizes a Moscow-Seoul warming that holds the potential to extend de'tente from Europe into Asia and eventually to reunify Korea.

Two huge armies face each other across a tense line in Korea, which, of the four countries left divided by World War II, remains the one that could explode (again) in war. To ease the conflict somewhat, the United States, while staying faithful to its longtime ally South Korea, has edged into a limited formal dialogue with Moscow's and Beijing's ally, the hermit state of Communist North Korea. Meanwhile, the Soviet Union has also crossed alliance lines, increasing contacts with the South by trade, by participation in the 1988 Seoul Olympics and now by a nimble political initiative promising the establishment of formal ties. The sequence gives Moscow and Seoul a far closer and more conspicuous connection than Washington and Pyongyang, North Korea's capital, and may stimulate some competitive diplomacy in return.

As welcome as such exchanges are, more is required to bring the Korean peninsula peace and security. Right off, the Soviets need to begin matching Washington's careful military retrenchment in South Korea with a similar retrenchment in North Korea; the two big powers together should see to a controlled military stand-down. North Korea's other nearby patron, China, which has been widening its own links to Seoul, must naturally be consulted on a Korean settlement. Japan, economic powerhouse of East Asia, also has to be drawn in.

A Korean settlement, of course, cannot be imposed from outside. It can only arise from negotiations among Koreans. South Korea, its longing for reunification tempered by deep and well-justified suspicion of Northern treachery, has nonetheless devised an American-encouraged ''North policy'' of economic and political outreach to the divided country's other half, and especially to the other half's patrons and friends. North Korea has remained largely defiant and inflexible, and it has seemed it would stay so at least as long as Kim Il Sung is in charge -- unless the North's 78-year-old Stalinist dictator draws the proper conclusion from the Gorbachev-Roh breakthrough and decides that his country must adjust to new times, too. That is the key to peace -- and it is also a long shot.