Prime Minister Justin Trudeau Thursday hailed the release of a Toronto pastor in North Korea, signalling his national security adviser helped get Hyeon Soo Lim out of prison with the aid of Sweden.

"I am pleased and relieved to confirm that Pastor Lim has been released from jail in North Korea and that he will soon be reunited with his family and friends in Canada," Mr. Trudeau said in an early morning statement.

This came after North Korea's state media reported Wednesday that Mr. Lim, serving a life sentence in a labour camp, was freed on "sick bail."

Story continues below advertisement

Mr. Trudeau said little about what led to Mr. Lim's release - "operational security considerations prevent us from discussing the matter further" - but noted the role of Daniel Jean, his national security adviser, and Sweden.

Opinion: Trump has threatened himself, and the rest of us, into a corner

Explainer: North Korea's missiles: What's happened so far, and what could happen next

"The government of Canada was actively engaged on Mr. Lim's case at all levels," Mr. Trudeau said.

"In particular, I want to thank Sweden, our protecting power in North Korea, for assisting us," he added.

"This week, a Canadian government delegation led by Daniel Jean, my special envoy, travelled to Pyongyang, North Korea, to discuss Pastor Lim's case. Pastor Lim's health and well-being remain of utmost importance to the government of Canada, and we are working to ensure that he receives any required medical attention."

Mr. Lim's release comes at a time when Pyongyang is at the centre of high-pitched international tension over its nuclear-missile program that has dominated attention from Washington to Beijing.

Story continues below advertisement

Mr. Lim's family is "relieved, grateful, excited, anxious to see him home," said family spokeswoman Lisa Pak in a statement Thursday.

"We are grateful to all parties involved; Prime Minister Trudeau, Minister [Chrystia] Freeland, and all the public servants in Global Affairs who have worked behind the scenes with North Korean authorities to bring Reverend Lim home," Ms. Pak said. She also confirmed that Mr. Lim will be receiving medical attention.

"We would also like to extend a particular thank you to Ambassador Torkel Stiernlöf and the staff at the Swedish Embassy for their tireless efforts and critical role in securing his release. There is a long way to go in terms of Reverend Lim's healing."

It's unclear whether the international tensions swirling around North Korea had any effect on the case of Mr. Lim, about whom family and friends were growing increasingly worried.

It's possible that Mr. Lim's release might be North Korea's way of sending a goodwill message at a time of high tension, to try to portray itself as a reasonable country that can negotiate, said Steven Denney, a doctoral fellow at the Munk School of Global Affairs' Asian Institute.

"I think that North Korea understood that it was on thinner ice than usual," he said, after the case of Otto Warmbier, an American University student who fell into a coma while imprisoned in North Korea – he was released June 13, but died six days later. It's possible the regime is being more cautious with Mr. Lim's health problems, Mr. Denney said.

Story continues below advertisement

Pyongyang had reason to avoid a repeat of what happened to Mr. Warmbier.

"That incident met with major U.S. and international backlash against North Korea. It catalyzed discussions over additional human-rights-focused sanctions and prompted countries to re-evaluate their policies on tourism to the North," said Andrea Berger, senior research associate at the Middlebury Institute of International Studies.

U.S. President Donald Trump set a confrontational tone Tuesday, when he said the United States would respond to North Korean threats "with fire and fury the world has never seen."

That heightened speculation the United States was moving toward war with North Korea, though U.S. Secretary of State Rex Tillerson sought to dial back the fears of imminent military conflict as he flew to Guam on Wednesday.

He told reporters that Mr. Trump was sending "a strong message to North Korea in language that [North Korean leader] Kim Jong-un would understand." Even so, the United States has in recent weeks delivered a steady drumbeat of warnings to Pyongyang that it must stand down from its pursuit of functional warheads for long-range nuclear missiles.There has also been tension between Washington and China, as Mr. Trump repeatedly pressed Beijing to use its influence to rein in its neighbour.

China signalled what could be a major shift by casting a United Nations Security Council vote on Saturday to impose sanctions on North Korea. If China enforces those sanctions, it would have a major impact on its neighbour, as most of North Korea's trade goes through China. The UN vote appeared to mark a new willingness by Beijing to openly pressuring its neighbour with punitive measures.

Story continues below advertisement

China's influence has always been crucial in diplomacy with North Korea – few other countries have functioning relationships with Pyongyang. Canada has no direct diplomatic relations with Pyongyang, but Mr. Trudeau's Liberal government is actively working to warm political and economic ties with Beijing. Foreign Affairs Minister Chrystia Freeland was in China on Wednesday for formal talks with Chinese Foreign Minister Wang Yi, arriving after Mr. Jean and the delegation were already in North Korea.

Jack Kim, special adviser to HanVoice, a Canadian non-profit organization that advocates for North Korean human rights, said it is not clear if there was a quid pro quo between Canada and North Korea for Mr. Lim's release. However, he said Mr. Jean's visit to Pyongyang may have been enough for the North Koreans.

"What they usually want is a high-profile official going to North Korea. … Daniel Jean, in the Canadian sense, does fit that bill," Mr. Kim said. "It's kind of a show of respect to the North Korean regime that these foreign officials are coming to fetch these incarcerated folks out."

Mr. Kim said the government's decision to send Mr. Jean – as opposed to a sitting legislator or even a cabinet minister – to Pyongyang was a "good compromise" in an effort to not give into the North Koreans.

Mr. Lim, who served in one of the largest churches in Canada and travelled to North Korea regularly on humanitarian missions, was sentenced by the country's Supreme Court in December, 2015, to a lifetime of hard labour after being accused of attempting to overthrow the regime.

In his early 60s, Mr. Lim is said to suffer from high blood pressure and is believed to have lost a significant amount of weight since his capture.

Story continues below advertisement

Mr. Lim's family had become more concerned for his welfare since the death of Mr. Warmbier, who had been held in North Korea for 17 months.

Mr. Warmbier, sentenced last year to 15 years' hard labour for trying to steal a propaganda item from his hotel during a tour, died in a Cincinnati hospital just days after being released in a coma. The circumstances of his death remain unclear.

Staff and members of Mississauga's Light Korean Presbyterian Church had long been praying for Mr. Lim's release and well-being. Assistant pastor John Bae arrived Wednesday morning for 5:30 prayers and found out Mr. Lim had been let go an hour later.

"We were praying so hard for good news," he told The Globe and Mail shortly after removing a "Bring Lim Home" sign from his office door. "We're thankful for the Canadian government's work."

Raymond Cho, a Progressive Conservative member of the Ontario legislature who has known Mr. Lim for 20 years, said he has not heard any official word about the pastor's release but believes failing health played a major factor.

"His health must be pretty bad, I suspect," Mr. Cho said before Mr. Trudeau's comments Thursday.

Story continues below advertisement

Mr. Cho said North Korea could be trying to "save face" in the international community by releasing Mr. Lim.

"I don't think it will help if [Mr. Lim] becomes any more sick and dies there. At this stage, North Korea is getting more and more isolated after this continued missile testing and the nuclear-arms program," he said.

"Whatever the reason, I'm exceedingly happy he's coming home."

Conservative Senator Yonah Martin, who is ethnically Korean, had previously lobbied for Mr. Lim to be freed. "I'm relieved," she said, following the news of Mr. Lim's release.

She said Mr. Warmbier's death had been a "catalyst" for the release of the Canadian pastor.

Ms. Martin said Mr. Lim had lost more than 20 kilograms. Last year, Mr. Lim told CNN he spent eight hours a day digging holes at a labour camp where he had not seen any other prisoners.

His family had sent him needed medication but was worried he was not receiving it. A letter sent by Mr. Lim to his family further raised concern that he was unwell.

"The tone in the letter," Ms. Martin said, gave "the sense that his health was definitely being affected.

"How could it not? Being away from family, away for such a long period of time after being isolated, being under watch and under hard labour in North Korea."

With reports from Josh O'Kane in Toronto and Michelle Zilio in Ottawa