SEOUL/TORONTO (Reuters) - North Korea freed a Canadian pastor serving a life sentence on humanitarian grounds, the Canadian prime minister and North Korea’s KCNA news agency said, just hours after the United States warned it would counter any threat from the North with “fire and fury.”

FILE PHOTO - South Korea-born Canadian pastor Hyeon Soo Lim stands during his trial at a North Korean court in this undated photo released by North Korea's Korean Central News Agency (KCNA) in Pyongyang December 16, 2015. KCNA/File Photo via REUTERS

There was no clear connection between the release of Hyeon Soo Lim and the heightened rhetoric between Washington and Pyongyang.

A statement from Canadian Prime Minister Justin Trudeau’s office on Thursday said that Lim had been freed and “will soon be reunited with his family and friends”.

His case was taken up by a delegation led by the country’s national security adviser that had gone to North Korea earlier in the week, it said. Sweden’s embassy in Pyongyang, which represents several Western nations in the insular nation, had also helped, the statement said.

“Operational security considerations prevent us from discussing the matter further,” it said.

Lim, who served in one of the largest churches in Canada, had been sentenced to hard labor for life in December 2015 after North Korea accused him of attempting to overthrow the regime.

“Strategically, North Korea perhaps hopes to engender some goodwill from Canada as tensions rise,” said Charles Burton, a former Canadian diplomat in China. “They hope that Canada presents some moderating influence on the Trump administration.

“(But) I do not think it is directly connected to the tensions the U.S. president has ratcheted up. North Korea is concerned he would die in prison.”

North Korea has in the past attracted the attention of Washington and visits by high-profile Americans with the detention and release of U.S. citizens.

KCNA said Lim had been released on “sick bail” by the country’s Central Court for humanitarian reasons.

Lim is expected to return to Canada later on Thursday and will be hospitalized on arrival at his wife’s request, a source familiar with the matter said. His family is arriving separately.

“So far, it has been confirmed that government officials and a doctor are accompanying Reverend Lim,” said the source, speaking on condition of anonymity because they were not authorized to speak to media.

Lim’s family had become more concerned for his welfare since the death in June of American student Otto Warmbier, who had been held in North Korea for 17 months. Warmbier, sentenced last year to 15 years’ hard labor for trying to steal a propaganda item from his hotel, died in a Cincinnati hospital days after being released in a coma. The circumstances of his death remain unclear.

Canadian Senator Yonah Martin, who advocated for Lim’s release, said Lim was hospitalized during his imprisonment.

“They were sending medication but there was a question as to whether he was actually receiving it in the way he should.”

North Korea is still holding three Americans. The U.S. State Department said last week it would ban U.S. nationals from traveling to the isolated country from September.

Lim’s Toronto-area church has said he visited the North more than 100 times since 1997 and helped set up an orphanage and nursing home. Last year, Lim told CNN he spent eight hours a day digging holes at a labor camp where he had not seen any other prisoners.

On Wednesday, North Korea said it was considering plans for a missile strike on the U.S. Pacific territory of Guam, just hours after President Donald Trump, unhappy with Pyongyang’s nuclear weapons program, told the North that any threat to the United States would be met with “fire and fury.”