An international trade agreement embraced by President Barack Obama and the Republican-controlled Congress is drawing fire from many presidential candidates, illustrating the populist shift of both parties in the age of Donald Trump.

Contenders ranging from Democratic front-runner Hillary Clinton to Republican Sen. Ted Cruz of Texas have spoken out against the 12-nation Trans-Pacific Partnership the administration is hoping Congress will pass next year, even though both previously supported Mr. Obama’s trade policy—and could...