NAFTA has received very little love of late. President Trump beat up on NAFTA to secure votes in the U.S. election. Now that he is President, he has put the trade agreement on the chopping block, seeking to renegotiate it in the hopes of securing a better deal with Mexico. As NAFTA’s third member, Canada has been dragged into the fight.

This is not the first time Canada has been dragged into a NAFTA fight against its will. In 2012, a U.S.-headquartered drug company, Eli Lilly, notified the Government of Canada that it was suing Canada for violating NAFTA in relation to two of its drug patents. The alleged offence? Canadian courts found the patents to be invalid under Canadian patent law. Lilly alleged that Canadian courts violated minimum standards of treatment guaranteed to foreign investors under NAFTA and expropriated Lilly’s investments in its two drugs, Strattera and Zyprexa.

Many have viewed Lilly’s NAFTA claim as sour grapes after they lost in court. Critics have expressed concern that Lilly’s claim was a backdoor attempt to re-litigate drug cases, using NAFTA to obtain what was otherwise unavailable to them.

The case brought by Lilly is exactly the type of case that has irked opponents of modern trade deals. By allowing investors to sue governments for damages, trade agreements are said to elevate the rights of foreign investors over domestic sovereignty. This very issue nearly torpedoed the CETA agreement with the EU, until a compromise could be reached. The Lilly case has loomed large as major trade agreements such as the Trans-Pacific Partnership have reached their endgames.

Proponents of sovereignty and fair trade can finally breathe a sigh of relief. Last week, the Canadian Government emerged victorious in its five-year battle with Lilly. With over $15 million in legal bills between the parties, a NAFTA tribunal found no merit to Lilly’s claims and awarded approximately $5 million in costs to Canada. The good news is that we no longer need to worry that trade tribunals will become supranational courts of appeal over domestic property law disputes.

The Lilly dispute centered on the “promise doctrine” under Canadian patent law, under which patented inventions must meet the promises set out in the patents, or else risk being found invalid. Lilly argued that this doctrine was a dramatic departure from pre-NAFTA patent law and out of step with the law of other countries. The tribunal disagreed, refusing to question the Canadian judiciary’s own interpretation of pre-NAFTA patent law and finding that changes to patent law were incremental and evolutionary.

The most consequential part of the tribunal’s ruling is its consideration of when judges’ decisions can be challenged under NAFTA. The tribunal was unwilling to shut the door to the possibility of a NAFTA violation based on a radical change in domestic law. However, the tribunal set a high threshold for liability, finding that judicial decisions can ground a NAFTA challenge only in very exceptional circumstances, in which there is clear evidence of egregious and shocking conduct.

The Government’s victory was resounding. The tribunal found, for example, that under any plausible standard, the impugned Canadian court decisions were neither arbitrary nor discriminatory. Rather, the tribunal found that Canada’s promise doctrine is rationally connected to legitimate policy goals intended to draw the line between speculation and invention in evaluating patents.

The U.S. Government’s response to the Lilly decision is anyone’s guess. The Obama administration had filed a brief with the tribunal challenging application of NAFTA to judicial decisions. However, President Trump seems to have no qualms about challenging the decisions of “so-called judges”, by tweet or otherwise.

On the other hand, the President’s rationale for withdrawing the U.S. from the Trans-Pacific Partnership trade agreement appears to be at least partially based on extraordinary remedies available to private investors. Lilly’s claim against Canada is arguably the very scourge the President and others are seeking to remove from future “free and fair” trade agreements. Lilly’s loss ought to foster confidence in the current investor rights framework.

Canada has not had the luxury of picking its NAFTA fights. The Government defended judicial sovereignty against Lilly, and now it must defend free trade altogether in dealing with President Trump. Time will tell whether Canada can navigate NAFTA renegotiation as adeptly as it defended Lilly’s claim. In the meantime, Canadians can breathe a collective sigh of relief that we have not unwittingly placed our independent, non-elected judiciary at the mercy of foreign corporations.