(Bloomberg) -- President Donald Trump has been boasting about creating manufacturing jobs in states key to his re-election, but an emerging recession in the sector threatens to reverse that trend and imperil his message.

A decline in manufacturing jobs in coming months could hurt Trump in Rust Belt swing states such as Michigan, Ohio and Pennsylvania and could give Democrats a weapon against the president.

Trump traveled to Pennsylvania on Tuesday to make his case. “Factory floors across this land are once more crackling with life,” Trump told workers at a Royal Dutch Shell Plc plant in Monaca, northwest of Pittsburgh. “Our steel mills are fired up and blazing bright. The assembly lines are roaring.”

But Trump faces U.S. manufacturing output declining in consecutive quarters, the common definition of recession within the industry, the result of global weakness and a trade war between the U.S. and China.

So far, job growth has helped Trump make his case.

Payrolls in manufacturing totaled about 12.9 million workers in July, the most since November 2008, according to Bureau of Labor Statistics data. Since Trump took office in 2017, factory employment has increased by about a half million workers after stagnating in the prior two years.

But hiring momentum in the sector has started to fade. In the six months through July, 38,000 jobs have been added at factories, the fewest for a similar period since January 2017, when Trump took office.

Trump campaigned in 2016 on revamping trade deals to revive America’s industrial base -- a strategy that helped him pick off the historically Democratic states of Michigan, Pennsylvania and Wisconsin that Hillary Clinton took for granted. Democrats carried those three states in every election from 1992 to 2012 and they will likely need them to win in 2020.

Nationally, manufacturing jobs accounted for 11.9% of employment in counties Trump carried in 2016 compared with 6.7% in counties Clinton carried. In Pennsylvania, Michigan and Wisconsin, manufacturing’s share of employment averaged 17.9% in Trump counties versus 8.5% in Clinton counties, according to a Brookings Institution analysis of December 2018 employment data.

“There is no doubt that a core portion of Trump’s base is a group of former and current manufacturing workers,” said Mark Muro, a senior fellow at the Brookings Institution’s Metropolitan Policy Program. “This is an important part of his base, and it has also been an important part of the story he tells of having the back of the middle-class little guy.”

The benefit Trump derives from the story in his campaign will depend on what happens with jobs if output continues to decline.

The Fed’s latest industrial production report last month showed U.S. factory output declined at a 2.2% annualized pace in the second quarter after a 1.9% rate of decline in the previous three months. Within specific industry groups, metals, machinery, textiles, paper and petroleum and coal were among those that experienced outright production downturns during both quarters.

Another gauge of American manufacturing activity fell in July to an almost three-year low, dragged down by slower production and shaky export markets that help explain the Federal Reserve’s decision to reduce interest rates last month.

At least one Democratic presidential candidate has highlighted manufacturing declines.

“Despite Trump’s promises of a manufacturing ‘renaissance,’ the country is now in a manufacturing recession,” Senator Elizabeth Warren wrote in a Medium.com post last month.

The downturn in the index of factory activity is consistent with a recent trend of manufacturing weakness throughout the world. Producers are beset by a combination of tepid global economies and trade policies and tariffs that have left supply chains at some companies in disarray.

While manufacturing makes up only about 11% of the U.S. economy, the risk is that further weakness will extend to service providers and prompt those companies to reduce investment and limit hiring.

--With assistance from Ryan Haar, Justin Sink and Sahil Kapur.

To contact the reporters on this story: Vince Golle in Washington at vgolle@bloomberg.net;Mike Dorning in Washington at mdorning@bloomberg.net

To contact the editors responsible for this story: Alex Wayne at awayne3@bloomberg.net, Justin Blum, Scott Lanman

©2019 Bloomberg L.P.