The sudden release of a Canadian held for two years in China on suspicion of spying comes after a high-stakes campaign to secure his freedom, including an unusual and unannounced visit four months ago by the director of the Canadian Security Intelligence Service, who met with Chinese officials to try to persuade them that Kevin Garratt wasn't a spy.
On Thursday, a bearded Mr. Garratt landed in Vancouver and embraced his family, a free man. He had been accused by Chinese authorities of stealing military and defence research secrets and charged with espionage.
His release puts a sudden end to a major irritant between Canada and China less than a week before Premier Li Keqiang arrives in Ottawa for an official visit, and caps an extraordinary effort by the government of Canada, its embassy in Beijing and two prime ministers to push for Mr. Garratt's release.
The visit to China by CSIS director Michel Coulombe, Canada's top spy, was one element of that effort, according to multiple sources with knowledge of the meeting. When Mr. Garratt was indicted in January, China's state media said investigators had found evidence he had accepted tasks to gather intelligence for Canada.
Mr. Coulombe met with Geng Huichang, the minister in charge of China's powerful state security apparatus, to deliver the message in person that Mr. Garratt, a Pentecostal pastor, did not work for CSIS.
The Canadian had first come to China in 1984 and had taught English, operated a kindergarten, sold coffee and conducted humanitarian work in North Korea. He was a missionary, not a spy.
But from the outset, no Canadian intervention seemed to have any effect. Citing state secrecy provisions, China blocked Canadian officials from meeting Mr. Garratt and his wife, Julia, with whom he was initially detained, for months.
Julia was released on bail last February and subsequently allowed to return to Canada. But Chinese officials barred the Canadian government from attending Mr. Garratt's half-day trial this April. The Chinese court was then supposed to deliver a verdict in June, but requested an extension, continuing a pattern of protracting proceedings against Mr. Garratt.
In public and in private, Canadian leaders pressed his case with the highest levels of the Chinese government – Stephen Harper in 2014, on his last trip to China as prime minister, and Justin Trudeau from his first call to Beijing as PM.
This June, Mr. Trudeau used a brief meeting with China's Foreign Minister Wang Yi in Ottawa to push for Mr. Garratt's release, a tense confrontation just moments before Mr. Wang angrily lashed out at a Canadian reporter who also asked about the case.
Mr. Trudeau repeatedly brought up Mr. Garratt on his first trip to China as Prime Minister earlier this month, including at a private dinner in the Forbidden City with the Premier, a senior government official said. The official said there were indications on the China trip that Mr. Garratt's case was heading in a "positive" direction.
But nothing changed.
"It was almost at the point where everyone was losing hope," said Simeon Garratt, the couple's eldest son.
"And then you get the good news."
On Tuesday, the Chinese court issued its ruling – the contents of which have not been described by authorities or the family. Shortly thereafter, "we got a call and they he's coming back," Simeon said. A statement from the family said he was deported.
On Thursday morning, Mr. Garratt landed in Vancouver.
"Honestly, he looks great – a lot better than I was expecting. He's in good spirits, and I think he's extremely happy," Simeon Garratt said. "It's really exciting."
In a statement, Mr. Trudeau credited the work of those in Ottawa and Beijing.
"The government of Canada has been seized of this case at the highest levels. We want to thank consular officials who work behind the scenes every day in support of Canadians abroad," Mr. Trudeau said in a statement.
"We remain deeply impressed by the grace and resilience of the Garratt family, especially Kevin and Julia."
The senior official insisted there was no quid pro quo – even in the face of three things the Chinese want from Canada: the approval of an oil pipeline to the West Coast; lifting of limits on Chinese state investment in the oil sands; and an extradition treaty to send back allegedly corrupt Chinese officials living in Canada.
"Absolutely not," the official said.
Luo Zhaohui, China's ambassador to Canada, referred questions to the Canadian government. James Zimmerman, an American lawyer in Beijing who acted for Mr. Garratt, thanked Canadian officials. "The family appreciates the strong, persistent efforts of the Canadian government to secure Kevin's release," he said.
In more than two years of detention, Mr. Garratt was kept under constant surveillance and repeatedly questioned as Chinese authorities scoured the papers and computers they seized from a coffee shop he had operated in Dandong, a Chinese city that borders North Korea.
Mr. Garratt occasionally took pictures of goods travelling into North Korea, his family has said. He also travelled into North Korea for humanitarian reasons. Westerners who enter the isolated country are sometimes asked by foreign intelligence services to describe what they have seen.
Still, Mr. Garratt's detention was widely seen as retribution for Canada's arrest of Su Bin, a Chinese businessman arrested in Canada on suspicion of stealing U.S. fighter-jet secrets. Mr. Su was extradited to the U.S. and, in July, sentenced to 46 months in prison after pleading guilty to conspiring with Chinese military officers in a hacking scheme.
In detention, Mr. Garratt's health deteriorated. Locked in a room with lights that never turned off, he developed an irregular heartbeat.
For his family, it was galling to hear Mr. Li, the Chinese Premier, promise earlier this month that he would be "treated in a humanitarian way."
His release, however, comes amid hints of a softening tone in Beijing. In recent months, authorities have agreed to move a human-rights lawyer to a new prison after he went on a hunger strike, and given early release both to an imprisoned pastor and a man serving his fifth prison sentence for political activism that dates back to the Tiananmen Square protests.
China's Supreme Court also released a new regulation requiring publication of all verdicts within seven days, even in sensitive political and state-security cases, such as the one against Mr. Garratt. It comes into force Oct. 1.
"I've seen a number of small signs that Beijing is more open, or more reasonable, in dealing with sensitive cases. I hope it continues," said John Kamm, founder of the Dui Hua Foundation, which petitions for release of political prisoners.
But he, too, gave credit to the Canadian government.
"Persistent high-level pressure is so important," he said. "The release of Kevin Garratt is an excellent example that in fact it can and does work."