As President Trump moves to fulfill one of the central promises of his campaign, to get tough on an ascendant China, he faces a potential rebellion from a core constituency: farmers and other agricultural producers who could suffer devastating losses in a trade war.

Mr. Trump’s threat to impose tariffs on Chinese goods came with a presidential declaration that trade wars are good and easily won. But the action has injected damaging uncertainty into the economy as Republicans are already struggling to maintain their hold on the House and the Senate in a difficult election year.

While the battle for control of the House will be waged in large part in the suburbs, rural districts in Southern Illinois, Iowa, Arkansas and Missouri could prove important. And control of the Senate could come down to Republican efforts to unseat Democrats in North Dakota, Indiana, Missouri and Montana all states staring down the barrels of a trade war’s guns.

With farmers angry and worried as China vows to retaliate, many Republicans find themselves torn between loyalty to a president who remains broadly popular in rural states and the demands of constituents, especially farmers, to oppose his tariffs.

In North Dakota, a major soybean-producing state, Representative Kevin Cramer, a Republican who is running for the Senate, sounded restrained this past week when he urged Mr. Trump to “take a more measured approach” to China. By Friday, he sounded panicked.

“I contacted the Secretary Perdue to urge him to use every tool in the Farm Bill, including Commodity Credit Corp programs, to protect agriculture producers from effects resulting in potential trade actions against China,” he wrote on Twitter, referring to Agriculture Secretary Sonny Perdue. “Farmers must know the Administration has their back & I urge them to act swiftly.”

China’s aggressive response to Mr. Trump’s tariffs is aimed squarely at products produced in the American heartland, a region that helped send him to the White House. A trade war with China could be particularly devastating to rural economies, especially for pig farmers and soybean and corn growers. Nearly two-thirds of United States soybean exports go to China.

The tariffs have not yet gone into effect, and the administration is engaging in back-channel talks with the Chinese to try to resolve their differences.

In the meantime, Mr. Trump has been escalating his threats, and shows no sign of backing off. On Thursday night, he threatened to impose tariffs on an additional $100 billion in Chinese products.

Trump administration officials argue that the tariffs on Chinese goods, while not intended to help certain American industries, are necessary to prevent China from continuing to violate international trade rules. They say that less aggressive measures by past administrations failed, and that China has stolen American jobs and technology that are the key to future prosperity.

“It’s not possible to have true gain without the pain,” said Dan DiMicco, a trade adviser to Mr. Trump during the presidential campaign. “The battle is worth the victory, and we will win.”

But farm-state Republicans like Mr. Cramer believe that their constituents could be a casualty, and they are begging the Department of Agriculture to intervene.

Mr. Trump has directed the department to implement a plan to help farmers cope with the damage from tariffs. But few details have been forthcoming about how such a program would work or how much it might cost. And it is not clear how much the Agriculture Department could do to remedy the damage done to key trading relations in a global economy.

The secretary of agriculture has some authority to help farmers by creating new programs that could draw on funds from the Treasury. For instance, the secretary could direct the Commodity Credit Corporation, a government-owned entity, to purchase soybeans to buoy farmers’ revenues, said Kent Conrad, a former Democratic senator from North Dakota.

In the past, these powers have been used to provide relief from wildfires and other natural disasters, farm groups said. But such a program could be time-consuming and costly.

“All of that has serious consequences,” Mr. Conrad said. “It has costs to the government at a time when the deficits and debt have already soared, and we are going to have a trillion-dollar deficit.” The federal budget deficit, despite the strong economy, reached $598 billion for the first half of the current fiscal year, the Congressional Budget Office said on Friday, $71 billion more than was recorded during the same period last year.

If the White House does end up subsidizing farmers, that may open trade conflicts on other fronts. Chad P. Bown, a senior fellow at the Peterson Institute for International Economics, said that such a measure could spark trade challenges from countries beyond China, which would object to unfair competition from American agriculture.

Patrick Delaney, a spokesman for the American Soybean Association, said his group was still focused on trying to prevent the tariffs from going into effect, rather than examining what kind of measures the administration might take to support farmers. “It’s a whole lot easier not to wreck the car in the first place than it is to think about what a repair might look like,” he said.

Farmers have been among the most organized groups in lobbying the administration about its trade policy. But as trade tensions with China have escalated, farmers say these complaints appear to be falling on deaf ears. Many of them are now complaining to Congress.

For Republicans like Mr. Cramer, who is in a tough race against an incumbent Democrat, Senator Heidi Heitkamp, the president’s threat to sharply escalate the administration’s tariffs on Chinese imports and China’s threat to retaliate against American farm products spells trouble in this year’s midterm races. Mr. Cramer’s aides did not respond to requests for comment.

“There’s no question that it puts Republicans in a tough spot, because they’ve got to talk to their farmers and affected business owners about the negative impact of the tariff, which I’m sure they are hearing complaints about,” said Scott Jennings, a Republican strategist in Kentucky. “On the other hand, they’ve got constituents who probably think it’s a good idea for the president to stand up to China.”

A number of Republicans are pushing back against the president. In Iowa, Representative David Young, who represents a district that Mr. Trump carried by just four percentage points, has publicly urged Mr. Trump to negotiate before imposing tariffs. His state is a major producer of soybean, grain and pork products, and farmers there are already seeing prices drop.

“I respect the president and what he’s trying to do, trying to level the playing field, trying to get those trade deficits down, but it always comes at the cost of agriculture,” Mr. Young said in an interview with NPR. “And can we start just by sitting down at the table?”

Iowa’s senators — Joni Ernst and Charles E. Grassley, both Republicans — have called on Mr. Trump to reconsider. In a statement, Ms. Ernst cited the “real danger that increased tariffs on U.S. exports will harm Iowa producers and undermine the rural economy,” and she said she had spoken directly with the president about it.

The clash with China began last month, when Mr. Trump imposed tariffs on foreign steel and aluminum, fulfilling a central promise of his campaign. China responded with tariffs on $3 billion worth of American products, including pork, fruit and other items.

Then, in late March, the president announced plans to impose tariffs on $50 billion worth of goods from China. Once again, China retaliated; this past week, it proposed its own tariff measure on $50 billion in American products, which, in turn, goaded Mr. Trump to propose the additional tariffs on Thursday night.

It remains to be seen if China will answer Mr. Trump’s latest tariff threat with an escalation of its own.

In addition to soybean farmers, car makers and Boeing would be hit hard by China’s tariffs. Many American companies purchase products from Chinese factories, while others rely on the country’s vast consumer market to sell their goods.

The trade spat with China also comes on the heels of Mr. Trump’s decision to withdraw from the Trans-Pacific Partnership, a trade accord that was to rope in countries on both sides of the Pacific in an alliance against a rising Beijing. The administration is also renegotiating the North American Free Trade Agreement. Both were valuable deals for American farmers, and Mr. Trump’s move to upend them had already set agricultural producers on edge.

Suffering has come quickly for the sector on the stock market. Investors dumped stocks linked to agriculture on Friday. Deere & Company and the fertilizer giant Mosaic dropped nearly 4 percent, while the fertilizer maker CF Industries fell by 4.5 percent.

While some farmers and lawmakers have expressed hope that Mr. Trump’s threats are merely a negotiating tactic, administration officials insisted this past week that was not the case.

“There is the potential of a trade war,” Steven Mnuchin, the Treasury secretary, said in an interview with CNBC. “There is a level of risk that we could get into a trade war.”

Mr. Mnuchin said he was hopeful that talks with his Chinese counterparts could avert a damaging escalation of tit-for-tat tariffs, but he declined to elaborate on the status of talks and whether he thought an agreement could be reached.

The president’s new economic adviser, Larry Kudlow, said Mr. Trump’s threat to China was not a bluff. “Trump is not just using tariffs as a negotiating card. He said that to me,” Mr. Kudlow told reporters on Friday.

But the White House strategy to press China to reform its economic behavior seemed unclear. Mr. Kudlow said that the administration was holding back-channel talks with the Chinese, but that he would not characterize them as negotiations. He added that the United States was considering providing China with a list of the changes the United States would like to see, but that it had not yet done so. “I cannot guarantee that, but it’s something that is under discussion,” Mr. Kudlow said.