WASHINGTON - In a stark reversal, Sen. Pat Toomey (R., Pa.) said Wednesday that he would oppose a major international trade deal whose prospects he once hailed, changing course as he faces a tough reelection and simmering voter anger against such pacts.

Toomey, a staunch free-market conservative, has promoted the benefits of international trade, and voted last year for a measure seen as crucial to completing the pending Trans-Pacific Partnership (TPP) between the United States and 11 Pacific Rim nations.

But in an op-ed article published Wednesday, Toomey said the details of the deal fell short of his hopes.

"Good deals require good negotiations," he wrote in the Pittsburgh Post-Gazette. But he said this agreement would not protect innovations by state pharmaceutical companies or open up markets to the state's dairy farmers, concluding, "The Obama administration has not gotten a good enough deal for Pennsylvania workers."

Toomey's shift came as public polls show him losing ground to Democratic challenger Katie McGinty in one of the country's most crucial Senate races, one that could affect the chamber's balance of power.

It also comes as rage against international trade has fueled support for GOP presidential nominee Donald Trump and forced Democratic rival Hillary Clinton to reverse her support of the deal.

McGinty has opposed the TPP and used Toomey's stand as a weapon in their contest.

"Pat Toomey has spent his entire career pushing bad trade deals and policies that ship Americans jobs overseas, so nobody is buying this ridiculous flip-flop," McGinty said in a news release.

Major labor unions opposing the deal also were not impressed. Pennsylvanians are too familiar with Toomey "to be fooled by this episode of pathetic pandering," said Richard Bloomingdale, president of the Pennsylvania AFL-CIO.

The TPP, awaiting ratification by Congress and officials in other countries, involves nations that account for roughly 40 percent of the global economy, including Japan, Mexico, and Australia.

Toomey last year praised the potential deal and in May and June 2015 voted in favor of "fast-track authority" for President Obama, a measure seen as crucial to helping the administration seal the pact.

That vote was seen as a proxy fight over TPP.

As the fast-track plan advanced, a Toomey news release said: "We are a big step closer toward creating more jobs, lifting wages, and boosting economic growth for Pennsylvania."

But writing Wednesday in the largest newspaper in Western Pennsylvania, where many blame international trade for economic decline, Toomey said: "We should not pass a flawed deal just to get a deal done."

Toomey's position now puts him at odds on the trade issue with pro-business groups that have been his vocal supporters.

But Toomey's move did not dull his image with those organizations aiding his reelection. The U.S. Chamber of Commerce remains "all in" for Toomey, a spokeswoman wrote.

The Club for Growth, a free-market group Toomey once led, said the outfit is "fully committed" to his victory.