MOSCOW, AUG. 20 -- In a move seen as testing already strained relations between Moscow and Tokyo, the Soviet Union has ordered the expulsion of a Japanese military attache on spy charges and asked a Japanese businessman to leave the country for allegedly seeking Soviet commercial secrets.

In Tokyo, the Japanese government said it was expelling a Soviet deputy trade representative for purchasing allegedly stolen documents detailing sophisticated aviation systems, Washington Post correspondent Margaret Shapiro reported. Japanese Foreign Ministry officials denied any connection between the expulsion and the Soviet announcement a few hours earlier.

The Soviet actions, announced today by the Foreign Ministry, mark the first time since World War II that a Japanese diplomat has been expelled from Moscow, Japanese officials here said. The Soviet moves were regarded as a reaction to the expulsion from Tokyo of four Soviet diplomats on spy charges last spring and a consequence of the scandal over illegal high-technology exports to the Soviet Union by the Japanese Toshiba Machine Co.

Foreign Ministry spokesman Gennadi Gerasimov said the Japanese ambassador to Moscow had been told yesterday that the embassy's naval attache, Nobuhiro Takeshima, 42, had been caught spying at the Black Sea port of Odessa on July 29. Japan's air attache in Moscow, Tomohiro Okamoto, was also accused of spying in Odessa, but he has not been expelled.

Gerasimov said Takao Otani, deputy representative of the Mitsubishi Corp., has also been asked to leave the country for attempting to extract commercial secrets from the Soviet Foreign Trade Ministry. He said Otani, 49, had also been involved in currency speculation and had violated Soviet laws governing foreigners' travel.

Japanese Ambassador Yasue Katori told Japanese reporters at a briefing this evening that the charges were "groundless."

The Soviet charges came after repeated public complaints in recent months about a "hostile" anti-Soviet campaign in Japan, which Soviet spokesmen said had erupted into demonstrations near Soviet offices and Soviet ships docked at Japanese ports.

On June 10, the Japanese ambassador was summoned to the Soviet Foreign Ministry by Deputy Foreign Minister Igor Rogachev and warned that some Japanese personnel, including diplomats, were engaged in unacceptable activities.

This month, at a Foreign Ministry press conference, Soviet officials showed slides and equipment to support year-old charges that a crate of ceramic pots shipped from Japan to the Soviet port of Nkhodka and west along the Trans-Siberian Railroad in early 1986 had been equipped with hidden cameras and devices to measure radioactivity.

Gerasimov said today that the Japanese ambassador was warned that the actions of Japanese personnel in Moscow could lead to a "worsening of relations -- relations that are not that simple."

Shapiro reported the following from Tokyo:

Japanese Foreign Ministry officials said the Soviet diplomat, Yuri Pokrovsky, had been ordered out for repeatedly failing to appear for police questioning about how he had obtained various documents dealing with computerized flight systems.

Tokyo police have alleged that Pokrovsky paid more than $65,000 over a period of months to a top official of Tokyo Aircraft Instrument Co., one of Japan's major aviation firms, for the documents, some of which were prepared for the Japanese Self-Defense Agency.