WHEN Ronald Reagan, running for president in 1979, proposed doing away with trade barriers between the United States, Canada and Mexico, he did so with his usual hyperbole. It would show that Americans were still capable of “dreaming up fantastic deeds and bringing them off to the surprise of an unbelieving world”, he declared. The North American Free-Trade Agreement (NAFTA) signed by his successor, George H.W. Bush, and by his Canadian and Mexican counterparts in 1992 could not live up to such hype. But the benefits were still substantial, especially in the early years. Trade among NAFTA countries nearly quadrupled in nominal terms after the treaty took effect in 1994 (see chart). Northern Mexico industrialised. Productivity jumped in Canada, which had signed a free-trade deal with the United States six years earlier.

But when the “three amigos”, as the leaders of the NAFTA countries call themselves, gather for one of their annual summits in Ottawa on June 29th, the mood will be uneasy rather than celebratory. The biggest reason for that is Donald Trump. Today’s amigos—Barack Obama, Justin Trudeau, Canada’s recently elected Liberal prime minister, and Enrique Peña Nieto, Mexico’s president, are like-minded leaders who can unblushingly call one another friends. No one imagines that Mr Trump, if he is elected the United States’ next president in November, will fit into that club. He has called NAFTA a “disaster”. Just as he wants a wall to bar Mexicans from the United States, he wants high tariffs to keep out the goods they manufacture.

Although Mr Trump will be the most troubling spectre at the triangular talks, he is not the only one. The proposed Trans-Pacific Partnership (TPP), which would include the three NAFTA partners plus nine other (mostly Asian and Latin American) countries, would largely supersede the North American deal. Mr Obama views it as an improvement because it includes environmental and labour protections that NAFTA lacks. It would also help remove non-tariff barriers that still thwart North American trade. But it would transform NAFTA’s ménage à trois into a clamorous throng of a dozen; the three amigos would become the 12 acquaintances.

The TPP may founder if the United States does not ratify it; that, too, would be unsettling. If Mr Obama fails to win congressional approval by the end of his presidency in January, Mr Trump would be unlikely to try. His rival, Hillary Clinton, initially a supporter of the TPP, has turned cool. Unnerved by the protectionist mood in the United States, Mr Trudeau and Mr Peña, who will pay a state visit to Canada before the summit, are drawing closer.

NAFTA needs new impetus. The agreement “was a framework for bigger and better things that was never realised”, says Jennifer Jeffs of the Canadian International Council, a think-tank. Security measures imposed by the United States at its borders after the September 11th terrorist attacks in 2001 continue to impede trade. Progress has been slow on harmonising regulations and product standards. New forms of business, such as e-commerce, have not been incorporated into the agreement (but are part of the TPP). Excess paperwork and ponderous regulation deter small and medium-sized businesses from exporting within North America, says Laura Dawson of the Wilson Centre, a think-tank in Washington, DC.

They persist in part because NAFTA matters much more to its smaller members, which trade mainly within the group, than it does to the United States. Mr Obama’s pivot to Asia, part of the motivation behind the TPP, was also a pivot away from Canada and Mexico. Mr Trudeau’s Conservative predecessor, Stephen Harper, had testy relations with both of his NAFTA partners. In 2009 he imposed a visa requirement on Mexicans to stem an increase in bogus claims for refugee status. The summit planned for 2015 in Canada was cancelled, partly because of the ill feeling that measure provoked.

This month’s meeting, with the affable Mr Trudeau presiding, will see a return to bonhomie. Mr Obama will become the first American president to address Canada’s Parliament since Bill Clinton did so in 1995. The new Canadian prime minister has tried harder than his predecessor to allay the United States’ security worries. This month Canada’s government introduced legislation to allow its officials to record travellers’ departures from Canada, a security measure long sought by the United States. Earlier this year Canada agreed to an expansion in the number of airports and train stations where American border guards could pre-clear travellers to the United States.

Mr Trudeau would be delighted if Mr Obama reciprocated by pushing American lumber producers, who complain that Canada subsidises exports of softwood, to settle their dispute. But the president is unlikely to provoke American voters, who are in a protectionist mood. The three leaders are expected to promise to co-operate more on climate change and to integrate further their energy markets (even though Mr Obama has rejected the proposed Keystone XL pipeline to deliver oil from Alberta’s tar sands).

But the main progress may be in relations between NAFTA’s two smaller members, which are one another’s third-biggest trading partners. Mr Trudeau has already indicated that he will end the visa requirement for Mexicans. Mexico’s government hopes he will announce that at the summit, though he may wait until the end of the year, when Canada is expected to expand its “electronic travel-authorisation system”, an entry requirement for visitors who do not need visas. Canadian companies are eager to take advantage of Mr Peña’s liberalisation of Mexico’s energy market. Calgary-based TransCanada and the Mexican subsidiary of Sempra Energy, an American firm, recently won a $2.1 billion contract to build and operate an 800km (500-mile) gas pipeline in Mexico.

Mexicans admit that the terrifying prospect of a Trump presidency is one reason to make better friends with Canada. “If negative sentiment towards Mexico in the US prevails, we’ll be looking for closer ties to other countries that are friends of Mexico,” said the country’s finance minister, Luis Videgaray, to the Globe and Mail, a Canadian newspaper. Vicente Fox, a former Mexican president, was blunter. Mr Trump will “declare a trade war on Canada”, he predicted.

Even if Mr Trump loses, NAFTA’s glory days may be over. A successful TPP would eventually supplant it; the TPP’s failure would signal less openness to trade. Mexico has signed deals with more than 40 countries, most of them since NAFTA took effect, and Canada is actively seeking new partners. The three amigos will proclaim undying friendship, predicts Carlo Dade of the Canada West Foundation, a think-tank. But, he fears, this month’s reunion may be the last.