Japan is looking toward next week's visit of Soviet Foreign Minister Eduard Shevardnadze as an opening toward improved relations with the one country seen here as a threat to Japanese security.

Prime Minister Yasuhiro Nakasone spoke last week of a "fruitful beginning" in new relations with the Communist superpower, with which Tokyo has conflicting claims over a cluster of small islands off the northern coast of Japan, and the Japanese leader even hinted that he would be willing to meet with Soviet leader Mikhail Gorbachev soon.

It has been 10 years since the last such high-level Soviet visit here. Shevardnadze's predecessor, Andrei Gromyko, visited in 1976, but Moscow has turned down several Japanese invitations since then, saying the atmosphere was not right.

Although the Soviet Union is eager for new development capital and technology, the fact that Shevardnadze is coming at all is still considered something of a breakthrough. But no one is expecting miracles. Many of the problems that Shevardnadze will discuss on his four-day visit here are rooted in a rivalry that dates back more than a century and has been reinforced by East-West tensions since the end of World War II.

His impending visit, and other signs of a thaw in relations, are viewed here as a result of the general easing in Soviet-U.S. tensions, but also as a signal that the Soviet Union under Gorbachev may be more willing to deal with Japan as a power in its own right and not just a forward military base of the United States, which has 50,000 troops stationed here.

More trade could result, but not because of any great repressed enthusiasm for it among the Japanese. Long cool to the Soviet market, the Japanese are expected to treat new capital and technology from their side as their main bargaining chip in any substantive talks.

In Japan's view, the main obstacle to improved relations is the Soviets' refusal to return the cluster of small islands that they seized from Japan in 1945. The Japanese say the islands, located just off Hokkaido, the northernmost of Japan's four main islands, have been fortified in recent years with 10,000 troops and 40 MiG23 jets.

Military tensions date to the 19th century, when czarist Russia and imperial Japan began clashing over control of Korea and parts of China and Siberia. In 1905, Japan defeated the Russians in a two-year war. It fought them again in Manchuria in 1938 and 1939 and in 1945, before its surrender ended World War II.

The Soviets for years have viewed Japan more as a U.S. military outpost than as an independent country. Viewed from Moscow, the Japanese islands resemble a blockade armada that seals off Vladivostok, headquarters of the Soviets' Pacific fleet.

Moscow frequently has said that its problems with Japan are rooted in the presence of U.S. troops. Japan, however, contends that the alliance is necessary for security and accuses the Soviets of upsetting stability with a Pacific buildup. It long has been angered by Moscow's seeming refusal to deal with it as a sovereign state.

Today, Japanese and Soviet jets and warships play cat-and-mouse in the Sea of Japan. Western intelligence reports say the Soviets have deployed 135 SS20 intermediate-range missiles in Siberia, many of them presumed to be targeted on Japan. In this charged atmosphere, the two countries never signed a peace treaty after World War II. But they maintain full diplomatic relations and engage in substantial trade -- about $3.9 billion worth last year. Japan also has invested in energy and other development projects in Siberia.

The two countries have managed brief periods of political cordiality in the past, but never for long. Relations reached a new nadir in the early 1980s, as Japan joined the United States in economic sanctions against Moscow for its actions in Afghanistan and Poland. Ties were jolted again after the Soviets shot down a Korean Air Lines jumbo jet that flew over Soviet territory near Hokkaido in 1983.

Signs of the current thaw began appearing more than a year ago. Nakasone met briefly with then-Soviet premier Nikolai Tikhonov while the two were in New Delhi to pay respects to slain Indian prime minister Indira Gandhi. This spring, Nakasone flew to Moscow after the death of Soviet president Konstantin Chernenko and spent an hour with the newly installed Gorbachev.

This fall, Japan, the Soviet Union and United States signed an agreement for closer cooperation along civil aviation routes in the northwest Pacific.

Trade between Japan and the Soviet Union began picking up, after stagnating early in the decade. The two signed a long-term agreement for Japan to buy wood products. The Soviets pressed Japan to provide automobile plant equipment and other capital goods, and Japan quietly eased many of its sanctions.

A joint project to develop natural gas discovered off the Soviets' Sakhalin Island, in which Japan has already invested $180 million, gained new momentum late in the year. The Soviets asked Japan to supply loans of about $2.3 billion more to finance development of the fields. Under the plan, Japan would purchase gas on long-term contract.

In the same period, Soviet statements about Japan began to soften. This month's discussions between Shevardnadze and Japanese Foreign Minister Shintaro Abe are expected to result in minor confidence-building measures, covering such areas as trade, taxation and cultural exchange, and perhaps agreement for Nakasone and Gorbachev to meet. The idea is to create a positive atmosphere for future substantive discussions.

It is not clear with what resolve the Japanese will press their claims to the disputed islands. Since the war, Moscow has alternated between suggesting that it would give back the smallest of them and refusing to acknowledge that there is any dispute over territory.

Either way, the Soviets insist that they are on firm legal ground. They count the islands as part of the Kurile group, which were awarded to them at the end of the war by agreement among the allies in the division of territory seized during Japan's expansionist stage. But Japan, supported by the United States, contends that the islands are not part of the Kuriles, have historically been part of Japan and must be returned.

Currently, Moscow's official position is that it will not discuss the issue. But press reports here say that Soviet officials have hinted privately to the Japanese that return of some of the islands may be negotiable. Foreign Ministry officials have denied the reports.

The official Japanese position is that all the islands must be returned. In any case, the government would have difficulty at home giving any important concessions to the Soviets without some form of progress on the islands. Their return is a nonpartisan issue in domestic politics, supported even by the Japan Communist Party.

Analysts consider it all but impossible that the Soviets would give up the larger ones, which Moscow sees as having strategic importance as gates to the Sea of Okhotsk and site of bases close to Japanese and U.S. bases. Return of the smaller islands, however, is considered possible, if still remote.

Japan's main bargaining chip, meanwhile, is its technology and capital; backing off from the alliance with the United States is not considered an option. The Soviets want Japan's help in developing the Baikal-Amur railway and other projects in Siberia. Japan, while always happy to do business, does not find itself in particular need of the Soviet market.