Greensburg, Pa. — THIS faded mining town east of Pittsburgh seems right out of “The Deer Hunter,” one of many blue-collar, gun-loving communities that dot western Pennsylvania. For Donald J. Trump, such largely white, working-class towns are crucial to his hopes in the presidential campaign — and that’s one reason he campaigned in this region on Tuesday. By rolling up large enough margins in former industrial strongholds like Greensburg — not just in Pennsylvania, but also in Michigan, Ohio and Wisconsin — he might offset expected losses in cities like Philadelphia, Detroit and Cleveland, enabling him to capture those pivotal states.

Mr. Trump’s “Make America Great Again” message resonates with many of this region’s workers, whose wages — and hopes — have been tugged downward by the abandoned steel mills and coal mines. Take Dennis Haines, 57, thrown out of work in January when the printing plant where he worked for 30 years closed. Mr. Haines, a member of the machinists union, said: “It’s either you stick with the establishment or you go for change. People want change. A guy like Donald Trump, he’s pushing for change.”

Not long ago, when the mines and mills were booming and unions were much stronger, organized labor’s power helped keep the region solidly Democratic. But no longer. For one thing, union membership is down in Pennsylvania, declining by 100,000 since 2008, to 747,000.

The blue-collar counties of western Pennsylvania have largely swung Republican as unions have grown weaker and evangelical churches stronger. Despite overwhelmingly endorsing Hillary Clinton, labor unions face a big challenge with frustrated workers like Mr. Haines.

That many white male union members are embracing Mr. Trump doesn’t necessarily mean overall union membership is moving right, however. In recent years, as unions have organized more government employees and low-wage workers, the percentage of union members who are black, Hispanic or female has risen — and those groups are solidly anti-Trump.

Andy Brumfield, 49, a unionized corrections officer at the county jail here, said he was excited by Mr. Trump’s promises to bring jobs back. “He can’t do any worse than the politicians that we have,” he said. He cheers Mr. Trump’s tough talk on trade and his vow to build a wall along the Mexican border. “People are coming across willy-nilly,” he said. “There are a lot of people who want to harm our country.”

An army veteran who served in the first gulf war, Mr. Brumfield is upset with Mrs. Clinton for supporting tougher gun control. “I don’t believe anybody has the constitutional right to take away anything from anybody,” he said.

Michael Korns, chairman of the Republican committee here in Westmoreland County, is confident that Mr. Trump can win Pennsylvania, where Mr. Obama defeated Mitt Romney in 2012 by a margin of 310,000 votes, 52 percent to 46.6 percent.

“Many voters feel that the Democratic Party, which they had supported for generations, has largely abandoned blue-collar workers,” Mr. Korns said. “There’s also increasingly a feeling that the Republican Party has abandoned them as well, that neither party has much interest in the day-to-day economics of working people. And then when Trump came in, he spoke to them, he grabbed them.”

G. Terry Madonna, a professor of public affairs at Franklin & Marshall College in Lancaster, said Mr. Trump might do considerably better than Mr. Romney, who lost every Rust Belt state except Indiana.

“It’s a combination of the frustration that a lot of Americans feel — white, blue-collar workers who believe the economy is passing them by, that there’s still a recession, that wages haven’t kept pace,” Mr. Madonna said. “There’s all this frustration, and then a master showman shows up who says he’ll stick it to the establishment.”

Mr. Trump’s views on trade, immigrants and Muslims are attractive to many blue-collar workers, but they could alienate moderate voters in Columbus, Ohio, and the suburbs of Philadelphia and Northern Virginia. Unless Mr. Trump does well in those places, Mr. Madonna said, he will lose Pennsylvania, Ohio and Virginia.

Labor leaders and Mrs. Clinton are intent on winning back union members. The A.F.L.-C.I.O. has endorsed Mrs. Clinton, calling her “an unstoppable champion for working families” while dismissing Mr. Trump as “an unstable charlatan who made his fortune scamming them.”

Mrs. Clinton recently spoke at a Pittsburgh union hall, where she echoed Bernie Sanders in denouncing income inequality. “We need both a growth economy and a fairness economy where profits and paychecks rise together,” she said.

On Tuesday, Mr. Trump spoke to applauding workers at a scrap-metal plant in Westmoreland County. He denounced “failed trade policies,” saying he would renegotiate Nafta and scrap the proposed Trans-Pacific trade deal. He also borrowed Mr. Sanders’s arguments to attack Mrs. Clinton from the left, saying she “voted for virtually every trade agreement.” He added that she has betrayed American workers in favor of “Wall Street throughout her career.”

Late this summer, unions will mobilize a nationwide campaign to knock on doors, mail out pro-Clinton literature and speak to members at their workplaces.

Tim Waters, the political director of the United Steelworkers, said his Pittsburgh-based union will warn its members that Mr. Trump isn’t pro-worker: “He’s a wolf in sheep’s clothing.”

Unions have compiled a long list of objections to Mr. Trump. In one debate, he said wages were too high. Many workers have sued his companies for cheating them on wages. His Las Vegas hotel is battling unionization.

“Every opportunity he’s had to help American workers or American jobs, he did the opposite,” Mr. Waters said. “He has had Trump-brand suits, shirts and ties made in Bangladesh, China and Honduras, everywhere but the U.S. He has imported workers to work at his facilities in Florida.”

Mike Podhorzer, the A.F.L.-C.I.O.’s political director, estimated that around one-third of union members back Mr. Trump.

“When we talked with union members and brought up the facts about Trump and how he would impact their lives, we got them to stop thinking about this as a spectacle and start thinking about how this would affect their paycheck, health care and kids’ education,” Mr. Podhorzer said. “A lot of those voters who were thinking about Trump really backed away.”

Tom Marino, a Republican congressman from northeast Pennsylvania who is the chairman of the Trump campaign in the state, is optimistic about his candidate’s chances. “It’s quite simple,” he said. “Donald Trump is out speaking about bringing jobs back to the U.S., which is particularly important to Pennsylvania because of steel and coal. Trump is a breath of fresh air who has created jobs.”

But some voters are reluctantly backing Mr. Trump simply out of frustration with the status quo. “We need someone who will say things are wrong and will push hard to fix them,” said Paul Myers, a 50-year-old steelworker. “Trump might be lying about bringing jobs back, but at least he’ll try to.”