The Office for National Statistics (ONS) said the UK's deficit on trade in goods and services hit £4.5 billion in July, shrinking from £5.6 billion in June.
The brighter picture for UK trade came after total exports jumped by £800m to £43.8bn, while total imports eased by £300m to £48.3bn.
Sales of jewellery and oil played a key role in driving up exports to the European Union by £1bn to £12.5bn over the period.
The plunge in the value of the pound to 31-year lows following Britain's vote to leave the EU has made UK goods more competitive on the global market, helping exports to grow.
The shrinking of the trade deficit will raise hopes that the economy can continue to grow in the third quarter despite initial fears that Britain was heading for a recession.
Howard Archer, chief UK and European economist at IHS Global Insight, said the result adds evidence to the economy's "current resilience".
"A major hope for the UK economy going forward is that the substantial overall weakening of the pound since the UK voted to leave the European Union in June's referendum will increasingly feed through to boost foreign demand for UK goods and services.
"While the pound has recently firmed from its post-Brexit vote lows, it is still at an extremely competitive level and is likely to remain so for an extended period," he added.
The ONS said total exports were lifted in July by rising sales of ships and fuel, which both stepped up by £500m.
There were smaller export increases from food, drinks, tobacco and machinery, but these rises were offset by a £500m fall in aircraft exports.
It came as car imports shifted into reverse, dropping by £300m.
Samuel Tombs, chief UK economist at Pantheon Macroeconomics, questioned whether the trade deficit was feeling the impact of sterling's drop in the wake of the Brexit vote.
"Looking ahead, the lesson from the past is that it takes at least a year for sterling depreciations to boost net trade, as it takes time for firms to re-negotiate contracts and exporters to invest in new capacity.
"In addition, multinational companies have warned vocally that they will hold back from investing and relocating production to the UK to take advantage of sterling's weakness until the UK's future trade arrangements are known. As such, the trade boost from sterling's depreciation looks set to be a damp squib."
Our BQ Bulletin emails will land in your inbox at 7.30am, Monday to Friday, with a mix of the latest local business news, national news, and features to inspire you. Sign up here!
Click here to read our privacy statement