© Darryl Dyck/The Canadian Press Meng Wanzhou, chief financial officer of Huawei, leaves home to attend her extradition hearing. OTTAWA — Senior Huawei executive Meng Wanzhou was released Friday after striking a deal with U.S. prosecutors in courtroom developments that will have major consequences beyond North America.

The Chinese telecom giant’s chief financial officer is free to return to China after a legal battle that started nearly two years ago.

On Friday, she first appeared by virtual link in a Brooklyn courtroom, where the judge approved a deferred prosecution agreement related to fraud charges against her.

Meng's deal with the Department of Justice resolved charges that underpin a U.S. extradition request at the heart of international tensions between the West and Beijing.

Later Friday, British Columbia Supreme Court Justice Heather Holmes approved the request to withdraw the extradition order. Attorney John Gibb-Carsley, who presented the request, called it the "final chapter" of the case.

Holmes thanked the legal teams and Meng.

"Ms. Meng, you have been cooperative and courteous throughout the proceedings, and the court appreciates and thanks you for that," Holmes said.

Canada's Justice Department released a statement after the hearing that stated Meng is now free to leave the country.

Canadian police arrested Meng in December 2018 at the Vancouver airport on a U.S. warrant . She’s accused of fraud in the U.S. connected to her alleged violation of American sanctions on Iran.

"Not guilty," Meng told the Brooklyn court through an interpreter after Judge Ann Donnelly read the charges against her, which include conspiracy to commit wire fraud, wire fraud, conspiracy to commit bank fraud and bank fraud.

Under the agreement, prosecutors will defer the charges until Dec. 1, 2022, four years from the day of her arrest. After that date, the government will dismiss the charges as long as she complies with the agreement.

As part of the deal, Meng admitted to basic facts behind the charges. Her obligations also include that neither she nor her lawyers can publicly dispute the facts agreed upon. If they do, the deal is off.

Donnelly ordered her release on the personal recognizance bond. Once Meng makes it back to China, it will likely be very difficult for U.S. authorities to lay hands on her or influence her behavior, even if she tries to at some point deny responsibility or say she was coerced into the deal.

The DOJ issued a release after Meng’s hearing.

Nicole Boeckmann, acting U.S. attorney for the Eastern District of New York, said in a statement that Meng’s admissions confirm that she made “multiple material misrepresentations” regarding Huawei’s business operations in Iran in an effort to preserve the company’s banking relationship with a financial institution.

“Meng’s admissions confirm the crux of the government’s allegations in the prosecution of this financial fraud — that Meng and her fellow Huawei employees engaged in a concerted effort to deceive global financial institutions, the U.S. government and the public about Huawei’s activities in Iran,” Boeckmann said.

In the release, the DOJ said the prosecution team continues to prepare for trial against Huawei.

"We look forward to proving our case against the company in court," said Kenneth Polite, assistant attorney general of the criminal division.

Meng's fight against extradition from Canada to the U.S., which started with her arrest more than 1,000 days ago, has become a key component in the tensions between the West and Beijing.

Her arrest angered Beijing, which has been demanding her release. If Meng secures her freedom, it could be seen as a big win for Chinese President Xi Jinping.

During a July meeting between Deputy Secretary of State Wendy Sherman and China's Vice Foreign Minister Xie Feng, Beijing's list of demands included a request that the U.S. unconditionally revoke the extradition request for Meng.

Her legal team and Department of Justice officials have held talks about a possible deferred prosecution agreement since last winter.

Meng, the daughter of Huawei founder Ren Zhengfei, had previously denied any wrongdoing.

Her case has angered Beijing. The Chinese government has called the U.S. charges politically motivated and has labeled Canada as an accomplice.

Days after her arrest, then-president Donald Trump said during an interview that he would be willing to intervene in her case if it would help the U.S. land a trade deal with China or serve other American national security interests.

John Bolton, Trump's former national security adviser, has since rejected the idea that politics are involved in Meng’s case.

Meanwhile, other individuals have been caught in the middle.

Nine days after her arrest, Chinese authorities arrested two Canadians — Michael Kovrig and Michael Spavor — on espionage charges.

Spavor, an entrepreneur who introduced basketball legend Dennis Rodman to North Korean leader Kim Jong Un , was given an 11-year sentence and a court date for Kovrig’s verdict has yet to be set.

Prime Minister Justin Trudeau has called the Canadians’ arrests “arbitrary” and has pushed for their release by rallying allies — including President Joe Biden. The president pledged earlier this year to work to free the men, known colloquially in Canada as the “Two Michaels.”

According to readouts, Biden and Trudeau have discussed Kovrig and Spavor during their conversations and meetings — including on a call this week.

“Human beings are not bartering chips,” Biden said in February after a virtual summit with Trudeau. “We’re going to work together until we get their safe return.”

The ordeals of the Two Michaels have captured the attention of diplomatic circles around the world. In a show of solidarity, representatives of more than 25 foreign missions joined Canadians at Ottawa's embassy in Beijing last month as Spavor’s court decision came out .

Kovrig, a Canadian diplomat on leave, has a direct connection to powerful figures close to Biden.

Before his appointment, the president’s national security adviser, Jake Sullivan, was on the board of the International Crisis Group, which employed Kovrig. And Robert Malley headed the ICG before becoming Biden’s special envoy for Iran; he has campaigned publicly for Kovrig's release.

The Globe and Mail reported Friday that Meng's plea agreement does not include a deal to free the two Michaels. It remains to be seen if Canada has its own understanding with China that could lead to their eventual release.

A few weeks after their arrests, a Chinese court toughened its sentence for another Canadian, Robert Schellenberg. The court changed his initial sentence of 15 years for drug trafficking to a death sentence.

Canada has been demanding clemency for Schellenberg.

John Kamm, founder and chair of The Dui Hua Foundation, told POLITICO that his discussions with Chinese officials as recently as Thursday evening indicated that the Chinese government will respond to Meng's release by freeing Spavor and Kovrig, and removing Schellenberg from death row.

“I believe there will be a decent interval between Meng's return and the deportations [of the Two Michaels], lest the impression be given that hostage diplomacy was indeed being practiced,” said Kamm, who has devoted the past 50 years to engagement with the Chinese government to free prisoners of conscience in China. “There's a good chance that Schellenberg's sentence will be reduced by the Supreme Court to a lengthy fixed term or to death with two year reprieve, which is essentially life in prison."

The Canadians’ cases have damaged Ottawa’s diplomatic relations with Beijing — and have long been Trudeau's top foreign policy challenge.

The courtroom development Friday came a few days after Trudeau won re-election.

Since Meng’s arrest, Trudeau has pledged to honor Canada’s extradition treaty with the U.S. and spoken about the importance of adhering to the rule of law and respecting the independent judiciary.

The prime minister has come under domestic pressure from prominent Canadians to free Meng as a way to spring Kovrig and Spavor from detention in China. He firmly rejected the calls, arguing it would put other Canadians at risk.

Trudeau has avoided open confrontation with Beijing in a delicate effort to free Spavor and Kovrig. In dealing with China, Trudeau has had to consider how much trade-dependent Canada relies on China, its second-biggest partner, to buy products ranging from iron ore to canola to lobster.

The release from Canada's Justice Department late Friday stated that it's a "rule of law country."

"Meng Wanzhou was afforded a fair process before the courts in accordance with Canadian law," the release said. "This speaks to the independence of Canada’s judicial system.”

Josh Gerstein, Phelim Kine and Leah Nylen contributed to this report.