Here’s how the Trump administration managed to thread the needle to attain what could be one of the most bipartisan trade deals in history:

How this deal is different from NAFTA.

The deal overhauls the 25-year-old NAFTA by establishing new rules for the internet age and imposing higher costs on auto companies that have plants in Mexico. And for the first time, violations of the agreement’s labor and environment rules can be redressed with penalties. It also removes certain protections for foreign investors while adding in provisions to prevent currency manipulation.

Yes, labor really likes this trade deal.

Unions have long vilified NAFTA for making it easier for manufacturers to locate production south of the border where a lax labor system, a cheap workforce and tariff-free trade under the agreement created the perfect conditions for taking jobs away from American workers and cutting wages in the U.S.

AFL-CIO President Richard Trumka. | Pablo Martinez Monsivais/AP Photo

This time, Mexico has passed a new law to overhaul its own labor system and agreed to have a “rapid-response” enforcement process that will pinpoint violations down to the factory level. Mexico is also eliminating what was regarded as government control of unions.

The tweaks Democrats demanded will also make it easier to root out labor violations and take away trade benefits if goods and services are found to have been produced by workers toiling under poor labor conditions.

Farmers won’t see big gains in exports.

Many of the agricultural provisions are the same as in NAFTA, which has already canceled most duties on food products moving across the United States, Canada and Mexico.

U.S. dairy and poultry producers — who were left out of the original agreement because of Canada’s protection of those sectors — have gained some small additional access north of the border.

The National Milk Producers Federation estimates over six years, the deal will add $548 million to dairy farm revenues. That’s just a small percentage of $2.1 billion in dairy exports to Canada and Mexico in 2018.

Wheat producers are eager to see a small but significant technical change: Canada will have to grade imports of U.S. wheat no less favorably than its domestic product.

There were other small tweaks: Canada won’t be able to put up barriers to trade for alcoholic beverages — a big gain for regions like California's wine country.

Carmakers will have to scramble to avoid tariffs.

Auto companies with factories in Canada and Mexico will have to meet more rigorous rules if they want to avoid paying tariffs on cars and trucks entering the United States.

At least 75 percent of a car must be made in North America to qualify for no tariffs. That’s up from 62.5 percent under NAFTA. In a bid to raise wages in Mexico and to keep jobs in the United States, about 40-45 percent of a vehicle must be made by workers earning at least $16 per hour.

The U.S. International Trade Commission estimates the new provisions will lead to a net increase of 28,000 full-time U.S. jobs. Employment in the auto-parts sector will rise, but slightly fewer Americans will be making finished vehicles because the added manufacturing costs will lead to higher prices, thus reducing consumer demand, the ITC said.

Free trade advocates such as the Peterson Institute for International Economics have criticized the changes as “protectionism” and predicted they will harm the competitiveness of the U.S. auto industry. But car companies have largely embraced the changes, since the alternative could have been Trump deciding to withdraw from NAFTA and disrupting supply chains built out over the last 25 years.

The deal takes stock of how the internet has changed trade.

The deal includes rules against preventing the free flow of data across borders. The three countries also can't require companies to store data locally.

The agreement will also prohibit the three countries from slapping customs duties on digital products like movies, books and other downloadable or streaming material — a boon for companies like Netflix or Amazon. The move also helps the U.S. fight efforts by other countries to impose tariffs on digital products.

Agreement is mum on climate change but is a bit greener.

In one sign of how much U.S. trade policy has evolved over the last three decades, the original NAFTA negotiated by former President George H.W. Bush did not have a labor or environmental chapter, forcing then-President Bill Clinton’s administration to negotiate a pair of “side letters” covering those areas to help win congressional approval of the deal in 1993.

Democrats have now won a commitment that all three countries will “adopt, implement and maintain” seven different multilateral environmental agreements, covering issues such as endangered species. Language in the deal will allow the United States to penalize Canada and Mexico if the governments shirk their obligations.

However, to the disappointment of many environmental groups, there still is nothing in the trade deal that requires countries to take steps to address climate change. That has prompted the Sierra Club, the League of Conservation Voters and the Natural Resources Defense Council to signal their likely opposition to the pact.

Drug companies don’t get their way.

The compromise deal is a blow to the U.S. pharmaceutical industry after special patent protections for new-age biological drugs were stripped out of the agreement. These drugs, engineered from living organisms, have led to new treatments for everything from arthritis to cancer. The move represents a shift in U.S. trade policy, which had sought to increase protections for the increasingly important and lucrative area of medicine.

POLITICO NEWSLETTERS Morning Trade A speed read on global trade news — weekday mornings, in your inbox. Sign Up Loading By signing up you agree to receive email newsletters or alerts from POLITICO. You can unsubscribe at any time. This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The change to the deal scrapped a 10-year period in which drug companies could keep test data and other information confidential from generic drugmakers. Democrats argued that the provisions would tie their hands in an effort to reduce the 12-year protection period enshrined in U.S. law.

The tweak to the deal and lack of Republican outrage is notable. The GOP held up movement on the Trans-Pacific Partnership negotiated by former President Barack Obama because a seven-year biologic protection period secured in that deal didn’t match U.S. law.

"Sen. Grassley is a strong supporter of intellectual property protections to encourage medical innovation, but the reality is that we have a divided government and compromise is necessary," said a spokesperson for Senate Finance Chairman Chuck Grassley (R-Iowa).

Drug companies also saw numerous other patent protections that became regular features in past trade deals jettisoned from the USMCA to ease passage among Democrats. Those rules could have made it harder for cheaper, generic versions of drugs to reach consumers faster.