Yangon: Two of the world’s most secretive nations, military-run Myanmar and communist North Korea, agreed here Thursday to restore diplomatic ties in a move analysts say may help them bypass Western sanctions.

The countries have both been branded “outposts of tyranny” by the United States but have had no formal relations between themselves for more than two decades.

That changed Thursday after the North’s deputy foreign minister Kim Yong-Il met with his Myanmar counterpart Kyaw Thu for about an hour in Yangon.

China’s ambassador to Myanmar, Guan Mu, was seen with them as they left the meeting and headed to a Yangon hotel.

About two hours later, Kyaw Thu announced a deal had been reached.

“This morning we signed an agreement to restore diplomatic ties,” Kyaw Thu told reporters.

“We have to notify the United Nations, according to their procedures, and then the UN will do some formalities and announce to the international community that our two countries will resume diplomatic ties,” he added.

Myanmar had indicated a year ago that it wanted to restore relations.

The United States has in the past warned of warming military ties between the two, and in 2004 accused North Korea of seeking to sell surface-to-surface missiles to Myanmar’s military government.

Both countries are international outcasts in their own way — Myanmar has been under military rule in various guises since 1962 and is widely accused of rights abuses.

Nobel peace laureate Aung San Suu Kyi, whose National League for Democracy party won 1990 elections but has never been allowed to take office, has spent more than a decade under house arrest.

As for North Korea, its people are impoverished but the hardline Stalinist regime led by the unpredictable Kim Jong-Il stunned the world with its first ever nuclear weapons test last October.

Myanmar severed ties with North Korea in 1983, after Pyongyang staged a deadly bomb attack in a failed assassination attempt on South Korea’s then president Chun Doo Hwan, who was on an official visit to Yangon.

Chun survived the blast but it killed 17 of his entourage, including four cabinet ministers, while 17 others were wounded. Four Myanmar officials also died.

One of the North Korean agents is still detained in Insein Prison outside Yangon.

The attack took place near one of Myanmar’s most cherished landmarks, the Martyr’s Mausoleum near the famous Shwedagon pagoda — a site Kim Yong-Il made a point of visiting shortly after his arrival here Wednesday.

Analysts said the two nations may have felt drawn together in recent years due to a shared perception they have a common foe in the United States and the West more broadly, analysts said.

“These countries are at odds with the US and the West. All countries that are odds with the US should work together, that is their idea,” Thailand-based analyst Aung Naing Oo said.

“It’s not a secret that the Burmese military admires North Korea for being able to square off with the United States with the nuclear issue,” he said.

“Beyond that, Burma needs friendship and North Korea is isolated and needs friendship as well,” he added, referring to Myanmar by its former name.

Closer ties could also provide more practical benefits, with both countries under a raft of sanctions — North Korea over nuclear weapons and Myanmar for rights abuses.

“There is an arms embargo on the Burmese military, so maybe the Burmese military is looking for (North Korean) arms systems using Burmese resources — like rice. You don’t have to pay with hard currency, you could barter,” Aung Naing Oo said.

The two countries may also believe that teaming up will provide them with better leverage in dealing with Washington, Myanmar military analyst Win Min said.

“For Burma, having North Korea will give some leverage in dealing with the US, so they can continue somehow to deal with their weapons systems,” Win Min said.