A Chinese technology executive held in Canada on US fraud charges has left the country after a deal with prosecutors, following years of diplomatic tensions over her fate.

Two Canadians detained in China on spying charges were released from prison and flown out of the country on Friday, Prime Minister Justin Trudeau said, just after a top executive of Chinese communications giant Huawei Technologies reached a deal with the US Justice Department over fraud charges and flew to China.

The frenetic chain of events involving the global powers brought an abrupt end to legal and geopolitical wrangling that for the past three years has roiled relations between Washington, Beijing and Ottawa.

The three-way deal enabled China and Canada to each bring home their own detained citizens while the US wrapped up a criminal case against a prominent tech executive that for months had been mired in an extradition fight.

The first activity came Friday afternoon when Meng Wanzhou, 49, Huawei's chief finance officer and the daughter of the company's founder, reached an agreement with federal prosecutors that called for fraud charges against her to be dismissed next year and allowed for her to return to China immediately.

As part of the deal, known as a deferred prosecution agreement, she accepted responsibility for misrepresenting the company's business dealings in Iran.

About an hour after Meng's plane left Canada for China, Trudeau revealed that Canadians Michael Kovrig and Michael Spavor were also on their way home.

The men were arrested in China in December 2018, shortly after Canada arrested Meng on a US extradition request. Many countries labelled China's action hostage politics.

"These two men have been through an unbelievably difficult ordeal. For the past 1,000 days, they have shown strength, perseverance and grace and we are all inspired by that, Trudeau said.

The deal was reached as President Joe Biden and Chinese counterpart Xi Jinping have sought to tamp down signs of public tension - even as the world's two dominant economies are at odds on issues as diverse as cybersecurity, climate change, human rights and trade and tariffs.

Biden said in an address before the UN General Assembly earlier this week that he had no intention of starting a new Cold War, while Xi told world leaders that disputes among countries need to be handled through dialogue and cooperation.

The US Government stands with the international community in welcoming the decision by People's Republic of China authorities to release Canadian citizens Michael Spavor and Michael Kovrig after more than two-and-a-half years of arbitrary detention. We are pleased that they are returning home to Canada, US Secretary of State Antony Blinken said in a statement.

As part of the deal with Meng, which was disclosed in federal court in Brooklyn, the Justice Department agreed to dismiss the fraud charges against her in December 2022 - exactly four years after her arrest - provided that she complies with certain conditions, including not contesting any of the government's factual allegations.

The Justice Department also agreed to drop its request that Meng be extradited to the US, which she had vigorously challenged, ending a process that prosecutors said could have persisted for months.

After appearing via videoconference for her New York hearing, Meng made a brief court appearance in Vancouver, where she'd been out on bail living in a multimillion-dollar mansion while the two Canadians were held in Chinese prison cells where the lights were kept on 24 hours a day.

Outside the courtroom, Meng thanked the Canadian government for upholding the rule of law, expressed gratitude to the Canadian people and apologised "for the inconvenience I caused.

Over the last three years my life has been turned upside down, she said.

It was a disruptive time for me as a mother, a wife and as a company executive. But I believe every cloud has a silver lining. It really was an invaluable experience in my life. I will never forget all the good wishes I received.

Shortly afterward, Meng left on an Air China flight for Shenzhen, China, the location of Huawei's headquarters.

Huawei is the biggest global supplier of network gear for phone and internet companies. It has been a symbol of China's progress in becoming a technological world power - and a subject of US security and law enforcement concerns.

Some analysts say Chinese companies have flouted international rules and norms and stolen technology.

The case against Meng stems from a January 2019 indictment from the Trump administration Justice Department that accused Huawei of stealing trade secrets and using a Hong Kong shell company called Skycom to sell equipment to Iran in violation of US sanctions.

The indictment also charged Meng herself with committing fraud by misleading the HSBC bank about the company's business dealings in Iran.

The indictment came amid a broader Trump administration crackdown against Huawei over US government concerns that the company's products could facilitate Chinese spying.

The administration cut off Huawei's access to US components and technology, including Google's music and other smartphone services, and later barred vendors worldwide from using US technology to produce components for Huawei.

The Biden White House, meanwhile, has kept up a hard line on Huawei and other Chinese corporations whose technology is thought to pose national security risks.

Huawei has repeatedly denied the US government's allegations and security concerns about its products.

Meng had long fought the Justice Department's extradition request, with her lawyers calling the case against her flawed and alleging that she was being used as a bargaining chip in political gamesmanship.

They cited a 2018 interview in which then-President Donald Trump said he'd be willing to intervene in the case if it would help secure a trade deal with China or aid US security interests.

Last month, a Canadian judge held off on ruling whether Meng should be extradited to the US after a Canadian Justice Department lawyer wrapped up his case saying there was enough evidence to show she was dishonest and deserved to stand trial in the US.

Comfort Ero, the interim Vice President of the International Crisis Group, Kovrig's employer, said they have been waiting for more than 1,000 days for the news.

Michael Kovrig is free. To Beijing: We welcome this most just decision. To Ottawa: Thank you for your steadfast support for our colleague. To the United States: Thank you for your willingness to support an ally and our colleague. To the inimitable, indefatigable, and inspiring Michael Kovrig, welcome home! Ero said in a statement.