LONDON — Kim Jong Un's top diplomat held talks with Iranian President Hassan Rouhani in Tehran on Wednesday, just a day after President Donald Trump reimposed sanctions on the Islamic republic.

North Korean Foreign Minister Ri Yong Ho also met with Iranian counterpart Javad Zarif Tuesday in an effort to bolster longstanding relations between the countries.

Ri's trip to Iran was the first by a senior North Korean official since President Hassan Rouhani was re-elected last year. It also follows Trump's June meeting with Kim in Singapore.

Iranian President Hassan Rouhani, right, greets North Korean Foreign Minister Ri Yong Ho in Tehran on Wednesday. Iranian Presidency Office via AP

The North Korean foreign minister said he had briefed Rouhani on the nuclear negotiations between Pyongyang and Washington, according to Iran's Donya-e-Eqtesad newspaper.

Iran and North Korea have maintained relations for decades.

Soo Kim, a former CIA intelligence analyst who specializes in North Korea, said that the Iran visit sent a message to the international community.

The North Koreans were taking a “two-pronged” diplomatic approach by continuing denuclearization negotiations with the U.S. while also pursuing diplomacy and “ally-building” with countries such as Iran.

“It’s a way to keep us on our toes," Soo Kim added. "They’re playing a game with us, they’re giving us hope that things are going to progress but at the same time they’re not really showing us anything concrete.”

Trump's announcement that the U.S. would withdraw from the 2015 Iran nuclear deal was followed by Tehran advising Pyongyang not to believe any promises made at the June 12 summit with Kim Jong Un.

In an interview with NBC News' Lester Holt in September, Rouhani also warned that Washington pulling out of the pact "would carry a high cost" because "no one will trust America again." The Iranian president added that "the greatest capital that any country has is trust and credibility."

North Korea achieved several technical milestones in its weapons program last year — launching its first three intercontinental ballistic missiles and conducting its most powerful nuclear test to date.

Pyongyang has tested a total of 23 missiles since Trump took office, and 15 of those tests involved nuclear-capable ballistic missiles. The November 2017 launch of which appeared to be an intercontinental ballistic missile, or ICBM, flew farther than any of Kim Jong Un's previous tests. The North claimed it could reach anywhere in the mainland U.S.

However, analysts say it's hard to prove or debunk North Korea's claim that it could hit faraway American targets such as New York or Washington.

While Iran has maintained its nuclear program is for peaceful purposes, before the June summit with Trump North Korea had repeatedly threatened to attack the U.S. and South Korea.

Andrei Lankov, a professor of Korean studies at Kookmin University in Seoul, said that there was "active cooperation of nuclear and missile issues" between Iran and North Korea.

He added that Pyongyang and Tehran "do exchange knowledge, they do probably exchange technology," describing it as "an open secret" that's been going on for many years.

Lankov said North Korea has been selling arms to Iran at least since the mid-1980s, including missiles used by Tehran during the Iran-Iraq War.

He described Iran as a "very profitable partner" for North Korea.

Lankov added: "North Koreans tend to make alliances with anti-American radicals of any kind."

Trump has called the Iran nuclear agreement "the worst deal ever" and has demanded Tehran end its military support for the Syrian government and regional militant groups like Lebanon's Hezbollah.

The U.S. is also seeking to get Iran to curb its ballistic missile program, which was not restrained as part of the nuclear deal. Tehran has maintained that its missiles are not designed to carry nuclear weapons.

What is it like to live in Iran right now as the Trump admin. ratchets up economic and rhetorical pressure?@NBCNews' @aliarouzi filed this dispatch Wednesday from Tehran. pic.twitter.com/CYVO3o4bsv — NBC News (@NBCNews) August 9, 2018

Critics of Trump's decision say that the Iranians had acceded to international inspections and dramatically reduced their nuclear program as a result of the landmark agreement. So it was working, and by stepping away from a pact that took years to negotiate and imposed important concessions on Iran, the Trump administration was making it less likely that Tehran wouid come to the negotiating table again soon, they say.

Before Trump withdrew from the deal, France's Emmanuel Macron, Germany's Angela Merkel and Britain's Theresa May had pleaded with the president to give them leeway to address his concerns in a "side deal," a new negotiation to limit Iran's missiles, extend the term of the original Iran deal, and confront Iran's support for terrorism.

Boris Johnson, who was Britain's foreign secretary when Trump removed the U.S. from the pact in May, highlighted that the U.K. and other European countries viewed the nuclear deal "as vital for our shared security" and were "fully committed to upholding it."

Despite warming relations with the U.S., North Korea remains subject to U.S. sanctions.

And like Kim Jong Un's government, Iran argues that sanctions are not conducive to negotiations.

"Negotiations and sanctions at the same time is meaningless," Rouhani said in a televised address on Monday. "If someone stands in front of his rival or enemy and pushes a knife against their arm and seeks talks, the response is that he should first put the knife in his pocket and come to the negotiating table and use logic."

North Korea's Ri has also delivered a scathing attack on the Trump administration for enforcing sanctions at the same time as trying to negotiate the denuclearizaton of North Korea.

Speaking at a security conference in Singapore on Saturday, Ri said Pyongyang would not act unilaterally and demanded that the U.S. undertake "confidence building" measures during negotiations.

"Confidence is not a sentiment to be cultivated overnight," he said.