BEIJING — China pledged Thursday to hit back at the United States if it sets off a trade war, issuing its strongest threat yet as President Trump prepares to impose more tariffs against China.

The White House is hours away from putting into effect sweeping steel and aluminum tariffs on its trading partners that have caused an international outcry. But more worrying to China are separate trade sanctions that Mr. Trump could impose under an investigation into China’s intellectual property practices. Hundreds of Chinese companies could be singled out in that process, known as a Section 301 investigation.

Speaking on the sidelines of the annual meeting of China’s legislature, Foreign Minister Wang Yi said, “History has shown that fighting a trade war has never been a correct way to solve a problem.”

“Especially given today’s globalization, choosing a trade war is a mistaken prescription,” Mr. Wang said. “The outcome will only be harmful. China would have to make a justified and necessary response.”

He did not elaborate on the measures that Beijing might take. But he urged the United States to “sit down peacefully” to constructively discuss finding a mutually beneficial solution.

China has told American executives that it will retaliate against American companies if Mr. Trump levies tariffs against Beijing, according to a business lobby group, the American Chamber of Commerce in China. The most likely targets would be airplane and agricultural companies — political constituencies that are important to Mr. Trump.

The group has said that trade tariffs imposed by the United States could also prompt Beijing to investigate American exports to China. China could say that these goods are sold below their fair value and subsidized by the United States.

China is now less dependent on trade than it used to be, even though on paper it has more to lose from a trade war. It exports more to the United States than it imports, according to an analysis by Capital Economics, a London-based research company. Exports to the United States contribute only 2 percent to China’s annual economic output, which is driven largely by domestic demand.

On Thursday, China released trade data that showed that its exports in February rose 44.5 percent from a year earlier, giving it a trade surplus of $33.7 billion for the month. Economists said, however, that this was a one-off and largely related to the Chinese New Year. Exporters usually rush to ship goods before closing for the holiday.