MOSCOW/SEOUL (Reuters) - Vladimir Putin, on his first visit to North Korea in 24 years, signed a mutual defence pledge with Kim Jong Un on Wednesday, underscoring just how far Russia has recast its relations with the only country to test a nuclear weapon this century.

Putin, who is locked into a major confrontation with the West over Ukraine, cemented his pivot to North Korea after nearly two decades of supporting United Nations sanctions against Pyongyang.

Depending on the exact wording of the pact, which was not immediately released, it could be a dramatic shift in the entire strategic situation in Northeast Asia, said Artyom Lukin, at Russia's Far Eastern Federal University.

"If Russia provides security guarantees to North Korea, then the DPRK becomes an analogue of Belarus, Russia's main ally in Eastern Europe," Lukin said, using the initials for North Korea's official name. "It will be an open challenge to the system of U.S.-centric alliances in Northeast Asia. And, of course, it will be a huge problem for Seoul and Tokyo."

While North Korea has a defence treaty with China, it does not have active military collaboration with Beijing like it has developed with Russia over the past year.

China, by far North Korea's largest trading partner and an increasingly important ally for Russia, has reacted cautiously to their burgeoning ties, avoiding any trilateral arrangement that might complicate its relations elsewhere.

'DRIVEN BY WAR IN UKRAINE'

The courting of Kim, which includes gifts of limousines, a tour of Russia's new space launch centre and a "strategic partnership" pact including a mutual defence clause, has alarmed the United States and its Asian allies.

Their spy agencies are trying to work out just how far the 71-year-old Kremlin chief will go - and what missile or even nuclear technology Russia might pass to North Korea in exchange for munitions to fight in Ukraine.

"The first visit by Putin in 24 years shows this is about what Russia can get from North Korea - and that is driven by the war in Ukraine," said Ramon Pacheco Pardo, professor of international relations at King's College in London.

Pacheco Pardo, who has written books about both Koreas, said that he expected Russia to share some knowledge and expertise for the development of North Korea's missile and nuclear programmes, though not Moscow's most advanced technology.

"I think this is a big change in relation to North Korea," he said. "Without the invasion of Ukraine, I don't think Russia would have felt compelled to share such technology."

Four diplomats who spoke to Reuters on condition of anonymity said they expected deeper ties with North Korea but said that Russia, as the world's biggest nuclear power, would be highly selective about what technology it shared with Kim.

Another Western diplomat, based in Seoul, said the extent of Russia's cooperation with North Korea was injecting a sense of urgency in Europe's engagement with countries such as South Korea and Japan and may lead to more shifts in global alliances.

Russia says its relations with Pyongyang will accord to international agreements and that it will not be told how to conduct its relations by any other power, least of all the United States.

Both Russia and North Korea have denied accusations by U.S. and allied officials, and U.N. sanctions monitors, that Pyongyang is sharing weapons for use in Ukraine.

'COMRADE KIM'

Putin said on Wednesday that Russia did "not exclude developing military-technical cooperation" with North Korea due to Western support for Ukraine.

"The deepening cooperation between Russia and the DPRK is something that should be of concern, especially to anyone that's interested in maintaining peace and stability on the Korean Peninsula," Major General Patrick Ryder, a Pentagon spokesperson, told reporters.

Putin's move towards North Korea is seen by diplomats as a major turning point in the international sanctions regime against North Korea, which was formed in 1948 with the backing of the then-Soviet Union.

In March, Russia vetoed the annual renewal of a panel of experts monitoring enforcement of longstanding United Nations sanctions against North Korea over its nuclear weapons and ballistic missile programmes. China had abstained.

The next day, Russia said that major powers needed a new approach to North Korea, accusing the United States and its allies of ratcheting up military tensions in Asia.

"The North Korea-Russia relationship started out as a marriage of convenience focusing on arms and tech transfers, so very transactional, but is now moving into payment systems, research collaboration and exchanges of different types," said Niklas Swanstrom, Director of the Institute for Security and Development Policy in Sweden. "It seems to have a depth that we have underestimated."

LIMITS

There are, though, limits to the relationship, say analysts.

Russia, the world's biggest nuclear power, is not interested in major nuclear proliferation, especially by a neighbour.

Nor is China, which despite growing clashes with Washington on foreign policy and trade issues is far from the international pariah that Russia and North Korea have become.

Both Moscow and Beijing, while ready to needle the United States and its Asian allies with public support for North Korea, have in the past criticised Pyongyang in public for its displays of missile or nuclear might.

Russia is due to outproduce all of the NATO military alliance on ammunition this year, so Putin's reliance on Kim is limited.

And while the Soviet Union helped North Korea build a research reactor at Yongbyon, the Soviet-era Kremlin was always wary of the nuclear ambitions of Kim Il Sung - the state founder and Kim Jong Un's grandfather - and found Pyongyang a provocative difficult partner, especially when it tried to nudge Moscow by deepening ties with China.

Russia has also historically balanced its approach to the North with its relations with South Korea, a U.S. ally but economic powerhouse, said Anthony Rinna, a specialist in Korea-Russia relations at Sino-NK, a website that analyses the region.

"By sidling up to North Korea, especially by upgrading their relationship to a comprehensive strategic partnership, Russia risks undermining its policy of diplomatic equidistance," he said.

(Reporting by Guy Faulconbridge and Josh Smith; Additional reporting by Minwoo Park in Seoul and Laurie Chen in Beijing; Editing by Alex Richardson)

By Guy Faulconbridge and Josh Smith