PITTSBURGH — Though they are both Democrats, John Fetterman, Pennsylvania’s lieutenant governor, and Bill Peduto, this city’s mayor, have their differences on the environment.

Mr. Fetterman, who toppled an incumbent Democrat in 2018 from the left, nevertheless calls Pennsylvania “the Saudi Arabia of natural gas” and sees extracting and taxing gas as critical to the state’s economy and the “union way of life.” Mr. Peduto lobbied unsuccessfully against a local petrochemical plant and is steering his once-struggling steel town to be independent of fossil fuels within 15 years.

But they agree on one thing: a pledge to ban all hydraulic fracturing, better known as fracking, could jeopardize any presidential candidate’s chances of winning this most critical of battleground states — and thus the presidency itself. So as Senators Bernie Sanders and Elizabeth Warren woo young environmental voters with a national fracking ban, these two Democrats are uneasy.

“In Pennsylvania, you’re talking hundreds of thousands of related jobs that would be — they would be unemployed overnight,” said Mr. Fetterman, who endorsed Mr. Sanders in 2016 before Donald J. Trump won his state, pop. 12.8 million, by just over 44,000 votes. “Pennsylvania is a margin play,” he added. “And an outright ban on fracking isn’t a margin play.”