China’s exports to the United States surged last month as its merchants rushed to fill orders ahead of a jump in U.S. tariffs on Chinese goods.

Its shipments to the United States climbed 13 percent in July from a year earlier, to $41.5 billion, after a roughly similar rise in June, customs data show.

At the same time, Beijing’s trade surplus with the United States — a frequent source of anger and threats from President Donald Trump — grew 11 percent to $28 billion.

Chinese exporters appear to be trying to ship their goods to the United States before tariffs that Trump is imposing in a fight over technology policy take full effect. The trade war between the world’s two biggest economies has forced many multinational companies to reschedule purchases and rethink where they buy materials and parts to try to dodge or blunt the effects of tit-for-tat tariffs between Washington and Beijing.

Beijing has warned that its exporters face “rising instabilities” after Washington slapped 25 percent duties on $34 billion of Chinese goods last month in response to complaints that China steals or pressures foreign companies to hand over technology. Beijing has retaliated against the U.S. tariffs with higher duties on a similar amount of American goods.

On Tuesday, the Trump administration announced that it would proceed with previously announced 25 percent tariffs on an additional $16 billion of Chinese imports starting Aug. 23. On Wednesday, China hit back by saying it would impose identical 25 percent punitive duties on $16 billion of U.S. goods, including cars, crude oil and scrap metal, also to take effect Aug. 23.

A Commerce Ministry statement labeled Trump’s decision to go ahead with the latest U.S. tariffs “very unreasonable.” Beijing’s retaliatory move was a “necessary response” to “safeguard its legitimate interests,” the ministry said on its website.

Escalating its tensions with Beijing, the Trump administration has also threatened to impose penalties on an additional $200 billion in Chinese exports to the United States. Beijing says it is ready to retaliate against $60 billion of American imports. (Beijing cannot tax an equal amount of U.S. products, because the United States exports far fewer goods to China than it imports.)

Tariffs are taxes on imports. They are meant to protect homegrown businesses and put foreign competitors at a disadvantage. But the taxes also exact a price on domestic businesses and consumers who buy imports and end up paying more for them.

In July, China’s global exports surged 12 percent, even faster than an 11 percent increase in June. At the same time, overall imports to China jumped 27 percent last month.

Exports to the rest of the world might have been boosted by a weaker Chinese currency. The yuan has declined by 8 percent this year against the dollar and by about 4 percent against a basket of global currencies. A weakening currency makes a nation’s goods more affordable for overseas buyers.

China’s trade conflict with the United States, coupled with weakening global demand, has compounded the challenges for Beijing. Economic growth has slowed since regulators tightened controls on bank lending to rein in surging debt.

The unusually strong July import figures reflected higher prices, according to Julian Evans-Pritchard of Capital Economics.

“We expect export growth to cool in the coming months, though this will primarily reflect softer global growth rather than U.S. tariffs,” Evans-Pritchard said in a report. “Import growth is likely to slow as domestic headwinds continue to weigh on economic activity.”

China’s global trade surplus narrowed by 40 percent from a year earlier to $28 billion. In the meantime, its trade gap with the 28-nation European Union contracted 8 percent to $11.2 billion.

China is running out of American goods to hit with retaliatory tariffs given the two nations’ lopsided trade balance. Last year’s imports from the United States totaled about $130 billion. That leaves only about $20 billion for penalty tariffs after increases that have already been imposed or threatened on U.S. goods are counted.

Beijing has stepped up efforts, so far without success, to recruit governments including Germany and France as allies. Those nations have criticized Trump’s tactics, but they share U.S. complaints about Chinese industrial policy and market barriers.