Three dozen union workers gathered outside city hall here on Thursday to rally against the global free-trade deals they believe have harmed Americans like them. Their candidate was Katie McGinty, the Democrats’ nominee for Senate in Pennsylvania. But their spiritual leader was Republican Donald Trump.

“He recognized there’s some problems we need to solve,” said McGinty, who is challenging Sen. Patrick J. Toomey (R), a free-trade advocate. “One, we have to stop bad trade agreements. . . . And two, we have to take the Chinese on when they manipulate their currency and dump goods in our markets.”

Just two days earlier, Trump had delivered a blistering speech at an aluminum recycling plant near Pittsburgh in which he called U.S. trade policies a ­“politician-made disaster” that has betrayed the working class. McGinty, surrounded by electricians, pipe fitters and steelworkers, declared that while Trump usually spouts “nonsense,” he had, in this case, “recognized a couple of truths.”

Of the many ways Trump, the GOP’s presumptive presidential nominee, has scrambled the 2016 campaign, it is his position on trade that has presented one of the most unexpected challenges for his rival, Hillary Clinton, the likely Democratic nominee. In an election season animated by economic anxiety, Trump, a New York business mogul, bucked Republican orthodoxy and powerful business interests such as the U.S. Chamber of Commerce in an appeal to blue-collar Republicans that helped propel him t o victory in the GOP primaries.

Clinton, who scrambled to move left on trade during her tough primary fight against Sen. Bernie Sanders of Vermont, now finds herself again facing attacks on the issue — this time from Trump. He used his Pittsburgh-area speech to disparage her association with a pair of major trade agreements — one negotiated by President Bill Clinton’s administration and the other by President Obama’s while she served as secretary of state.

For Hillary Clinton, the risk is not necessarily losing support directly to Trump but rather not inspiring enough enthusiasm among rank-and-file union workers, whose turnout and ground-level organizing have traditionally been crucial for Democrats.