President Vladimir V. Putin of Russia will visit North Korea this week for a meeting with its leader, Kim Jong-un, their second in nine months, as the two countries deepen military ties to support Mr. Putin’s war in Ukraine with North Korean weapons.Mr. Putin last visited North Korea in 2000, when he became the first Russian or Soviet leader to visit the nation. This week’s trip, beginning on Tuesday, highlights North Korea’s growing strategic importance for Mr. Putin, especially its ability to supply badly needed conventional weapons for the war in Ukraine.Mr. Kim met with Mr. Putin in Russia’s Far East last September, ushering in a new era of relations between the two countries.For Mr. Kim, it was a rare moment of his country, a pariah in the West, being sought after as an ally. For Russia, it’s a strengthening of ties with a country that is providing it with much-needed munitions for its war in Ukraine.The two countries announced the two-day visit on Monday. “At the invitation of the chairman of state affairs of the D.P.R.K., Kim Jong-un, Vladimir Putin will pay a friendly state visit to the Democratic People’s Republic of Korea on June 18-19,” the Kremlin said.Days before Mr. Putin’s arrival in Pyongyang, the North Korean capital, the Kremlin vowed to foster cooperation with North Korea “in all areas.”Pyongyang and Moscow were Cold War-era allies whose relations cooled after the disintegration of the Soviet Union. But in the past couple of years, they have grown closer again as a result of shared hostility toward the United States — Russia over its war against Ukraine and North Korea over its nuclear weapons program. As the war in Ukraine has dragged on, Russia has found itself in urgent needed of conventional weapons, especially artillery shells. North Korea has plenty to offer. In return, Mr. Kim wants to upgrade his weapons systems, and Russia has advanced military technologies and other aid to share.Since Russia launched the full-scale invasion of Ukraine in February 2022, North Korea has sent Russia thousands of shipping containers’ worth of munitions, officials from the United States and South Korea say. Moscow, they say, has reciprocated by sending thousands of containers filled with economic and other aid.In the weeks ahead of Mr. Putin’s visit, Mr. Kim flaunted what he has to offer Mr. Putin. While visiting munitions factories last month, he praised them for increasing production and showed off warehouses full of short-range ballistic missiles — of a kind similar to the North Korean missiles that Washington has said Russia fired at Ukraine.Both Moscow and Pyongyang deny arms trade, which is banned under United Nations sanctions. But at the Group of 7 summit in Italy last week, the G7 leaders condemned “in the strongest possible terms the increasing military cooperation” between the two nations, including Pyongyang’s export of ballistic missiles and Russia’s use of them against Ukraine.“The fact that President Putin is making this trip means that because of its war in Ukraine, Russia is badly in need” of North Korean weapons, Chang Ho-jin, the South Korean national security adviser, told Yonhap News TV over the weekend. “The North Koreans will try to get as much as possible in return, because the situation looks favorable to them.”Mr. Chang said South Korea had warned Moscow ahead of Mr. Putin’s trip that it “should not cross certain lines.” He did not elaborate. But some analysts in South Korea have speculated that during Mr. Putin’s trip, North Korea may seek Russian help in improving its nuclear weapons capabilities and try to reinstate a Cold War-era military alliance with Moscow.Things had looked grim for Mr. Kim until the war in Ukraine created opportunities for him.For years, his country’s economy was devastated by the sanctions the U.N. Security Council imposed to deter his nuclear weapons program. Mr. Kim’s attempt to lift the sanctions collapsed when his direct diplomacy with President Donald J. Trump ended in 2019 without an agreement.Mr. Kim’s answer was to double down on his nuclear weapons program, while envisioning a “Neo-Cold War” in which his country hoped to elevate its strategic value for China and Russia in Northeast Asia while the United States, Japan and South Korea expanded their own military cooperation.North Korea was among the few countries to openly support Mr. Putin’s invasion of Ukraine. In return, Mr. Putin invited Mr. Kim to the Vostochny Cosmodrome in the Russian Far East last year and indicated that Russia could help North Korea launch satellites. Mr. Kim wants satellites to better monitor his military targets but has had trouble putting them into orbit.Mr. Kim toured sensitive Russian space and military facilities during his trip to Russia last year, at one point toasting with Mr. Putin to what he called their “sacred struggle” against the “band of evil” in the West.Russia is barred by United Nations agreements from arming North Korea with military equipment, but the decision to welcome Mr. Kim into high-tech facilities that manufacture rockets and fighter jets underscored Russia’s ability to provide the sort of technology North Korea has long coveted in its standoff with the United States and its allies.Faced with an onslaught of international pressure over his invasion of Ukraine, Mr. Putin has tightened his relationship with American adversaries around the world, including in Iran, North Korea and Syria, posing challenges for Washington outside Europe.Closer cooperation between Pyongyang and Moscow has security implications for the United States and its allies. The use of North Korean missiles on the battlefield in Ukraine can provide North Korea with valuable data on how they perform against Western missile defense systems, defense experts said.The closer ties are already creating gaping holes in international efforts to strangle Mr. Kim’s ability to earn hard currency through illicit activities.In March, North Korean TV showed Mr. Kim and his daughter riding in a Russian Aurus limousine that Mr. Putin gave him despite a ban on exporting luxury items to Pyongyang. State-sponsored hackers from North Korea are increasingly using Russian cryptocurrency exchanges to launder stolen funds. Last month, the White House said that Russia was shipping refined petroleum to North Korea at levels that exceeded Security Council limits.South Korean analysts also worry that in return for North Korean weapons, Moscow may allow more migrant workers from North Korea to work in Russia and earn badly needed cash for Mr. Kim.Importing such workers from North Korea is banned under Security Council resolutions. But this year, Moscow made it easier to flout the resolutions by using its veto power at the Council to disband a U.N. panel of experts that had monitored North Korea’s compliance with international sanctions.Paul Sonne contributed reporting from Berlin.