Few believed President Donald Trump could pull it off. Yet he has made a deal with both Canada and Mexico, better than NAFTA for the United States.

The Mexico-U.S. trade deal announced at the end of August runs counter to conventional wisdom. President Trump is unpopular in Mexico, and leftwing President-Elect Andres Manuel López Obrador, known as AMLO, was firmly anti-Trump on the campaign trail.

On the surface, they are an unlikely pair to work well together. However, economic and political realities loom large and have necessitated a deal.

Democrats are skeptical of the deal and worried because any Trump success is bad for them and their agenda. They know the deal could attract labor support, a key faction of the Democratic Party’s political base. Thus, Democrats such as New York Senate Minority Leader Chuck Schumer have downplayed the deal as superficial.

The trade negotiations were stuck prior to AMLO’s election on July 1. Outgoing President Enrique Peña Nieto has credited AMLO with resolving the gridlock, and even Trump praised AMLO for his supportive role.

In fact, AMLO was the driving force behind reaching the deal. He and his advisors know Mexico is in dire straits economically and in no position for a trade confrontation with the United States.

Gross mismanagement and corruption have caused a steady devaluation of the Mexican peso. A U.S. dollar costs 60-percent more than it did six years ago when Peña Nieto took office. Basic-goods prices have doubled, leaving the population even poorer.

Foreigners hold more than 60 percent of Mexican-government bonds, so the peso is subject to their perceptions. The lack of a trade agreement with the United States, which buys 80 percent of Mexico’s exports, would put downward pressure on the peso and make economic conditions much worse.

Pemex, the state-owned petroleum company, is a symbol of Mexico’s economic woes. A pivotal source of revenues for the central government, these have plummeted over five years from 39-to-17 percent of budgetary income. Mexico now imports 75 percent of its gasoline, and U.S. light-crude shale now goes to Mexico.

Since Peña’s tenure, foreign companies have been permitted to explore for and produce petroleum. Facing political and economic pressure, AMLO has announced he will respect this law. Mexico has an acute need for foreign investment.

On the political front, 64 percent of Mexicans favor a trade deal with the United States. All political parties have fallen into line and approve of free trade and want it to continue.

Martin Godoy, a legal Mexican immigrant and country-club manager who sends monthly remittances to his family, explains that AMLO won because of awful economic conditions. These conditions make trade with the United States even more of an imperative. Without a deal, conditions would become so bad that the masses, AMLO’s base, would turn against him.

Although there is still a lack of publicly released details, what we do know suggests the outcome will be favorable to both Mexican and American workers. The specter of a trade war will not cloud the peso; Mexican unions will benefit; and exports of many products will continue and increase. US companies will have more opportunity in Mexico, creating more jobs back home.

Trump clearly understands how to use the levers of power. His negotiating style bothers his critics, but they produce results.

Mexico could not afford a US withdrawal from NAFTA without a replacement. Mexico, as Trump says, is very important for the United States, but we can much better withstand not having a deal than Mexico can. Regardless of AMLO’s ideology, he is constrained by economic realities and the needs and perceptions of his political base.

While both sides expressed their desire for Canada to be included, such was the Mexican need that they would have proceeded without Canada. That gave Trump extra leverage with Canada, which he used to America’s advantage.

Democrats issued statements opposing a Mexico-only deal, seeking to undermine Trump’s leverage. They prefer to sacrifice American interests for their anti-Trump politics.

Similar to Mexico, 74 percent of Canadian exports go to the United States. In key sectors, however, Canada still has a managed economy, so getting Prime Minister Justin Trudeau to agree to a revised deal was more difficult.

On October 1, Trump announced the US-Mexico-Canada Agreement (USMCA) had been concluded the day before. This was the deadline he had set for Canada to join the deal, and Trump overcame the media-hyped personal differences with Trudeau.

Now that the deal includes all three countries, the USMCA has a better chance of passage. It can be interpreted as a continuation of NAFTA, which requires 50 votes in the Senate rather than 60.

Trump will improve the lot of U.S. workers and businesses with the USMCA, and with a deal that is also good for Canada and Mexico. He has succeeded because he is practical, not ideological, and he is astute in understanding leverage and negotiations. He also benefited from Mexican support for open trade and AMLO’s responsiveness to his base.