He gets almost everything wrong. But last weekend Donald Trump got something right. To the horror of the other leaders of the rich world, he defended democracy against its detractors. Perhaps predictably, he has been universally condemned for it.

His crime was to insist that the North American Free Trade Agreement (Nafta) should have a sunset clause. In other words, it should not remain valid indefinitely, but expire after five years, allowing its members either to renegotiate it or to walk away. To howls of execration from the world’s media, his insistence has torpedoed efforts to update the treaty.

In Rights of Man, published in 1791, Thomas Paine argued that: “Every age and generation must be as free to act for itself, in all cases, as the ages and generations which preceded it. The vanity and presumption of governing beyond the grave is the most ridiculous and insolent of all tyrannies.” This is widely accepted – in theory if not in practice – as a basic democratic principle.

Even if the people of the US, Canada and Mexico had explicitly consented to Nafta in 1994, the idea that a decision made then should bind everyone in North America for all time is repulsive. So is the notion, championed by the Canadian and Mexican governments, that any slightly modified version of the deal agreed now should bind all future governments.

But the people of North America did not explicitly consent to Nafta. They were never asked to vote on the deal, and its bipartisan support ensured that there was little scope for dissent. The huge grassroots resistance in all three nations was ignored or maligned. The deal was fixed between political and commercial elites, and granted immortality.

In seeking to update the treaty, governments in the three countries have candidly sought to thwart the will of the people. Their stated intention was to finish the job before Mexico’s presidential election in July. The leading candidate, Andrés Lopez Obrador, has expressed hostility to Nafta, so it had to be done before the people cast their vote. They might wonder why so many have lost faith in democracy.

Nafta provides a perfect illustration of why all trade treaties should contain a sunset clause. Provisions that made sense to the negotiators in the early 1990s make no sense to anyone today, except fossil fuel companies and greedy lawyers. The most obvious example is the way its rules for investor-state dispute settlement have been interpreted. These clauses (chapter 11 of the treaty) were supposed to prevent states from unfairly expropriating the assets of foreign companies. But they have spawned a new industry, in which aggressive lawyers discover ever more lucrative means of overriding democracy.

The rules grant opaque panels of corporate lawyers, meeting behind closed doors, supreme authority over the courts and parliaments of its member states. A BuzzFeed investigation revealed they had been used to halt criminal cases, overturn penalties incurred by convicted fraudsters, allow companies to get away with trashing rainforests and poisoning villages, and, by placing foreign businesses above the law, intimidate governments into abandoning public protections.

Under Nafta, these provisions have become, metaphorically and literally, toxic. When Canada tried to ban a fuel additive called MMT as a potentially dangerous neurotoxin, the US manufacturer used Nafta rules to sue the government. Canada was forced to lift the ban, and award the company $13m (£10m) in compensation. After Mexican authorities refused a US corporation permission to build a hazardous waste facility, the company sued before a Nafta panel, and extracted $16.7m in compensation. Another US firm, Lone Pine Resources, is suing Canada for $119m because the government of Quebec has banned fracking under the St Lawrence River.

As the US justice department woke up to the implications of these rules in the 1990s, it began to panic: one official wrote that it “could severely undermine our system of justice” and grant foreign companies “more rights than Americans have”. Another noted: “No one thought about this when Nafta implementing law passed.”

Nor did they think about climate breakdown. Nafta obliges Canada not only to export most of its oil and half its natural gas to the US, but also to ensure that the proportion of these fuels produced from tar sands and fracking does not change. As a result, the Canadian government cannot adhere to both its commitments under the Paris agreement on climate change and its commitments under Nafta. While the Paris commitments are voluntary, Nafta’s are compulsory.

Were such disasters foreseen by the negotiators? If so, the trade agreement was a plot against the people. If not – as the evidence strongly suggests – its unanticipated outcomes are a powerful argument for a sunset clause. The update the US wanted was also a formula for calamity, that future governments might wish to reverse. But this is likely to be difficult, even impossible, without the threat of walking out.

Those who defend the immortality of trade agreements argue that it provides certainty for business. It’s true that there is a conflict between business confidence and democratic freedom. This conflict is repeatedly resolved in favour of business. That the only defender of popular sovereignty in this case is an odious demagogue illustrates the corruption of 21st-century liberal democracy.

There was much rejoicing this week over the photo of Trump being harangued by the other G7 leaders. But when I saw it, I thought: “The stitch-ups engineered by people like you produce people like him.” The machinations of remote elites in forums such as the G7, the IMF and the European Central Bank, and the opaque negotiation of unpopular treaties, destroy both trust and democratic agency, fuelling the frustration that demagogues exploit.

Trump was right to spike the Trans-Pacific Partnership. He is right to demand a sunset clause for Nafta. When this devious, hollow, self-interested man offers a better approximation of the people’s champion than any other leader, you know democracy is in trouble.

• George Monbiot is a Guardian columnist