In a sudden resolution to a diplomatic crisis between the U.S., China and Canada, a top Huawei Technologies Co. executive flew home as China released two jailed Canadians.

For nearly three years, Meng Wanzhou, Huawei’s chief financial officer, was under house arrest in Vancouver as she battled extradition to the U.S. on fraud charges. Across the Pacific, Michael Kovrig and Michael Spavor — detained within days of Meng’s December 2018 arrest — languished in Chinese jails, pawns caught in a geopolitical rivalry between the U.S. and China.

The seemingly intractable impasse came to a rapid resolution Friday after Meng struck a deferred prosecution agreement with U.S. authorities to resolve criminal charges against her. Within hours, the Supreme Court of British Columbia discharged her and Meng immediately left for the airport to board a chartered Air China flight back to Shenzhen, home to the Chinese technology giant’s headquarters.