Japanese Foreign Minister Yoshimasa Hayashi speaks to reporters at the ministry in Tokyo on Sept. 27, 2022. (Kyodo)

A Japanese diplomat was detained by Russia's Federal Security Service and accused of engaging in espionage after he obtained classified information in exchange for a payment, the spy agency said Monday, an allegation flatly denied by Tokyo.

Tatsunori Motoki, a consul at the Japanese Consulate General in Vladivostok, was declared persona non grata, in a rare move against Japanese diplomats in Russia, and has been ordered to leave the country within 48 hours following his detention. He was released after being held for a few hours, the Japanese government said Tuesday.

In Tokyo, the Foreign Ministry summoned Russian Ambassador Mikhail Galuzin on Tuesday to lodge a protest. Foreign Minister Yoshimasa Hayashi told reporters that detaining and interrogating a consul is a "clear violation of the Vienna Convention on Consular Relations" as well as of a consular treaty between Japan and Russia.

Hayashi said Russia's action was "totally unacceptable" as the consul had not committed an illegal act and he had been treated "coercively" by Russian authorities during his detention, including being blindfolded and physically restrained.

The ministry demanded that Moscow make a formal apology and ensure a similar incident does not happen again, Hayashi said, adding the government needs to take appropriate measures against Russia.

Chief Cabinet Secretary Hirokazu Matsuno told a press conference that the diplomat had no health problems and would leave Russia by Wednesday.

The incident occurred amid a cascade of economic sanctions imposed on Russia by Japan and Western nations over Moscow's invasion of Ukraine since late February.

The FSB said Motoki received classified information on cooperation between Russia and Asia-Pacific countries as well as on the impact of Western sanctions on Russia's Far East region. He is accused of paying for the information.

Local media released footage of the consul receiving documents at what appears to be an eatery and of him admitting to the accusations during FSB questioning.

In the wake of the economic sanctions, relations between Japan and Russia have soured. Designating Japan as an "unfriendly" country, Moscow has banned the entry of more than 400 Japanese lawmakers including Prime Minister Fumio Kishida and Hayashi.

In late March, Russia unilaterally announced it would suspend territorial talks with Japan over four disputed islands called the Northern Territories by Japan and the Southern Kurils by Russia, which Tokyo claims the Soviet Union illegally seized soon after Japan's surrender in World War II in August 1945.

The territorial dispute has prevented the two countries from concluding a postwar peace treaty.

In April, Russia's Foreign Ministry said it would expel eight Japanese diplomats, apparently in retaliation for an earlier decision by Japan to expel Russian diplomats.