Official figures showed exports rose 3.3% last month, compared to forecasts for a 2% drop.
Imports fell 5.6% in July, less than the expected 8.3% decline.
Still, analysts tip China’s economy will remain under pressure as Washington prepares to hit Beijing with a fresh round of tariffs next month.
“Looking ahead, exports still look set to remain subdued in the coming quarters,” Capital Economics’ Senior China Economist Julian Evans-Pritchard said.
The US has vowed to impose duties on $300bn (£246bn) worth of Chinese products on 1 September, after long-running trade negotiations between the two countries broke down.
Tensions between the world’s two largest economies intensified this week after the US officially named China a “currency manipulator” following a sharp drop in the value of the yuan against the US dollar.
The People’s Bank of China said on Monday that the slump in the Chinese currency was driven by “trade protectionism measures and the imposition of tariff increases on China”.
But central bank governor Yi Gang later said China would not engage in “competitive devaluations”.
A weaker yuan makes Chinese exports more competitive, or cheaper to buy with foreign currencies.
Nonetheless, fears of a currency war rattled markets earlier this week.
On Thursday, the PBOC set its official yuan midpoint below the key 7 level to the US dollar for the first time since 2008.
But the trading point was firmer than traders had expected, and was seen as a signal that authorities wanted to stabilise the decline in the currency.
The yuan steadied and stock markets moved higher in Asian trading hours.
Capital Economics’ Mr Evans-Pritchard said that in the coming months, “any prop from a weaker [yuan] should be overshadowed by further US tariffs and broader external weakness”.