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.”