Moments after the United States and 11 other Pacific Rim countries reached an agreement on the Trans-Pacific Partnership, Sen. Bernie Sanders, a surging contender for the Democratic presidential nomination, called the accord “disastrous.”

Mr. Sanders, an independent and self-identified socialist, has joined organized labor and liberal members of Congress in railing against the TPP, a historic free-trade agreement that would tie together 40 percent of the world’s economy, from Canada and Chile to Japan and Australia.

“I am disappointed but not surprised by the decision to move forward on the disastrous Trans-Pacific Partnership trade agreement that will hurt consumers and cost American jobs,” Mr. Sanders said in a statement. “Wall Street and other big corporations have won again. It is time for the rest of us to stop letting multi-national corporations rig the system to pad their profits at our expense.”

Mr. Sanders said he would do all he can to defeat the agreement.

“This agreement follows failed trade deals with Mexico, China and other low-wage countries that have cost millions of jobs and shuttered tens of thousands of factories across the United States,” he said. “We need trade policies that benefit American workers and consumers, not just the CEOs of large multi-national corporations.”

For the Obama administration, the TPP is legacy-making, a way to facilitate trade with countries America long hoped to engage more fruitfully. Cementing the accord took years of negotiations and, in recent months, drove a wedge between House Democrats who opposed the deal and Mr. Obama. Liberals fear the TPP will repeat some of the perceived mistakes of the North American Free Trade Agreement, a Clinton-era accord that Mr. Sanders and others blame for the outsourcing of American jobs.

In a rare move, the Obama administration found itself partnering with Republicans, including Senate Majority Leader Mitch McConnell, to support the agreement. Hillary Clinton, the frontrunner in the Democratic primary, has backed free-trade agreements in the past, but has been more wary of TPP, which is unpopular with the Democratic base.

Congress must ultimately vote to approve the accord, but it will be an up-down vote after the Senate and House gave Mr. Obama fast track authority earlier this year. The terms of the deal cannot be rewritten by Congress.

The Pacific accord would phase out thousands of import tariffs, as well as other barriers to international trade. It also would establish uniform rules on corporations’ intellectual property, open the Internet even in communist Vietnam and crack down on wildlife trafficking and environmental abuses.