Trade negotiators in Atlanta reached an agreement Monday that could affect everything from American exports of pharmaceuticals to New Zealand milk, Japanese rice, and Vietnamese textiles.

The deal, known at the Trans-Pacific Partnership, would more closely link the economies of 12 Pacific Rim nations and have sweeping global implications. President Obama has portrayed it as essential to cementing America's relationships in Asia, but critics such as Sen. Elizabeth Warren (D-MA) have portrayed it as a giveaway to corporate interests and a threat to US sovereignty.

Of all the issues under negotiation, the most contentious was legal protections for the pharmaceutical industry. American drug companies and their allies in the Obama administration have been pushing for new rules that would limit competition and boost drug prices. Other countries, with the support of public health groups, have pushed back, arguing that the measures would cost thousands of lives.

Ultimately, the negotiators split the difference. They agreed to language that would require some countries to expand the legal protections afforded to drug companies (and raise prices in those countries), but big drug companies got less than they wanted.

Now the action will move to Congress, which must approve the deal before it can take effect. We can expect the TPP to attract criticism from both ends of the political spectrum. Already, Vermont Sen. and presidential candidate Bernie Sanders (D-VT) has blasted the deal as a victory for "Wall Street and other big corporations," while Sen. Orrin Hatch (R-UT) has complained that the drug protections in the bill "fall woefully short" of what the industry had requested. Obama faces a big challenge convincing critics on both sides that while the deal might not be perfect, it's still better than no deal at all.

The TPP is a lot more than just a trade deal

The TPP is usually described as a trade deal, and it certainly will have important provisions related to trade. Negotiators have been considering liberalizing trade in cars and trucks, rice, dairy products, textiles, and a lot more.

But the agreement is also a lot more than a trade deal. It has more than two dozen chapters that cover everything from tariffs to the handling of international investment disputes. The reason these deals have gotten so complex is that people realized that they were a good vehicle for creating binding international agreements.

American negotiators — and, therefore, US interest groups — have had the most power in these negotiations

Modern trade deals include a dispute settlement process that helps ensure countries keep the commitments they make under trade deals. If one country fails to keep its commitment, another country can file a complaint that's heard by an impartial tribunal. If the complaining country prevails, it can impose retaliatory tariffs on the loser.

Interest groups have realized that this same mechanism can be used to enforce agreements on topics that have little to do with trade. And so a wide variety of interest groups — from Hollywood and the pharmaceutical industry to labor and environmental groups — have lobbied to include rules they favored in trade agreements. And because the US is the world's largest economy, American negotiators — and, therefore, US interest groups — have had the most power in these negotiations.

For example, at the behest of Hollywood and other US copyright holders, American negotiators have been pushing other countries to adopt our long copyright terms: the life of the author plus 70 years. International investors have pushed for an investor-state dispute settlement process that allows private investors to challenge foreign government policies before an impartial arbitration panel — a process critics such as Sen. Warren describe as a threat to American sovereignty. Drug companies want other countries to provide the same robust legal protections for new drugs they enjoy in the United States.

At the same time, labor and environment groups have pushed the Obama administration to incorporate their priorities into the agreement. The Obama administration insists the president has done just that, but so far these changes haven't gone far enough to convince these groups to endorse the agreement.

Drug protections were t he biggest sticking point

Previous trade deals already required TPP member countries to provide a minimum level of patent protection for pharmaceuticals, but most countries didn't provide protections as generous as those in the United States. Obama's trade negotiators wanted to include language in the TPP requiring other countries to make their laws more like those in the United States.

The most controversial provision of all concerns a type of drugs called biologics. These drugs are produced by biological processes rather than being synthesized in a chemistry lab. Drug companies say that patents, which protect a specific chemical formula, do not always provide adequate protection for biologic drugs, because it's often possible to find another compound that's biologically equivalent even though it has a different chemical structure.

Even the Obama administration's own budget wonks believe 12 years of protection is excessive

To prevent generic drug manufacturers from copying biologics and driving down their prices, big drug companies have used the regulatory process to limit competition. The Food and Drug Administration — and other regulatory agencies overseas — require drugmakers to prove that a drug is safe and effective before it can be introduced to the market. US law gives the creators of a drug exclusive rights to this data for a period of 12 years. Because clinical trials are expensive to perform, this effectively prevents generic drugmakers from creating competing drugs until the exclusivity period has expired.

Even the Obama administration's own budget wonks believe 12 years of protection is excessive. They've proposed reducing the protection period to seven years, and estimated that increased generic drug competition would save Medicare and other federal health-care programs billions of dollars. At the same time, Obama's trade negotiators have been pushing for language that would lock in 12 years of protection in the United States and require other countries — most of which offer shorter terms of five or eight years — to adopt the same 12 years of protection as the United States.

The full details of the compromise haven't been released — and might not be for another month — but media reports indicate that the US dropped its demand for 12 years of protection and settled for requiring five to eight years of protection instead. That's a significant concession for the United States, but it's still a victory of sorts for the pharmaceutical industry, since it will bar countries that currently offer five to eight years of protection from reducing it later. It also sets a floor, but not a ceiling — the United States will continue to offer 12 years of protection, and US negotiators may push for more lavish protections in future trade deals.

What happens next: months of waiting

While the TPP member countries have reached the outline of a deal, media reports suggest that not every detail of the agreement has been fully fleshed out. The New York Times predicts that it will take about a month for these details to be worked out and for the final text of the deal to be made publicly available.

After that, it will take another three to four months for Congress to enact a deal. Under the "fast-track" legislation authorizing Obama to negotiate the deal, the president must give Congress 90 days' notice before signing the trade deal, and then another wait another 30 days before introducing legislation implementing it. This means that even in the best-case scenario, Congress won't be able to vote on the controversial deal until early 2016. And it could be delayed by further wrangling, either among TPP member countries or within Congress.

Obama's big challenge will be that the deal has something for everyone to hate. Drug company allies like Orrin Hatch are disappointed that US negotiators didn't get the generous drug protections they'd sought — that will make them less excited about the deal. Meanwhile, public health groups believe eight years of protection is too long.

Nothing has happened in the past few months to mollify the TPP's many critics — most of whom come from the political left. We can expect many labor unions, environmental groups, and other left-leaning advocacy groups to lobby against the agreement.

However, Obama also has a huge advantage: The Republican leadership has firmly supported Obama's trade agenda, and was able to assemble majorities for fast-track legislation earlier this year. To pass the final deal, he simply needs to convince those same members of Congress — some of whom took a substantial political risk to back the fast-track bill — to vote with him again.