Vladimir Putin and Kim Jong Un have signed a comprehensive strategic partnership in a bid to unite against the US.
The agreement includes a vow of mutual assistance if either country is attacked.
The Russian leader is visiting North Korea for the first time in 24 years.
Russian state media said Mr Putin spoke to Mr Kim face-to-face for about two hours and thanked him for his country’s support for the war in Ukraine.
The Kremlin chief was treated to lavish ceremony when he arrived in the North Korean capital on Wednesday.
Huge crowds lined streets to greet the motorcade, chanting “Welcome Putin” and waving flowers and North Korean and Russian flags.
International concern has grown over an arrangement in which North Korea provides Russia with badly needed munitions in exchange for economic aid and technology transfers that could enhance Pyongyang’s nuclear weapons and missile program.
Mr Kim said the “fiery friendship” was now even closer than during Soviet times, and promised “full support and solidarity to the Russian government, army and people in carrying out the special military operation in Ukraine to protect sovereignty, security interests and territorial integrity”.
He also hailed Russia’s “important role and mission in preserving the strategic stability and balance in the world”.
“The situation in the world is exacerbating and changing rapidly,” Mr Kim said.
“In this situation, we intend to strengthen strategic interaction with Russia.”
Read more:
Analysis: Putin visit a diplomatic two-fingers to the West
Warning shots after North Korean soldiers cross border
North Korea is under heavy sanctions from the United Nations Security Council – of which Russia is a member – over its weapons program. Russia faces sanctions by the US and its Western partners over its aggression in Ukraine.
The two leaders also exchanged gifts, with Mr Kim reportedly receiving a Russian-built limousine, a tea set and an admiral’s dirk (dagger) and President Putin being given various works of art.
The visit comes after a major assault by Russian forces on the Ukrainian stronghold city of Kharkiv has faltered, amid heavy losses.
There is belief that Kyiv’s defenders, wracked by ammunition shortages for months, could eventually be back on the front foot as more Western weapons – including F-16 fighter jets – arrive in Ukraine.