A deficit of £9.2bn on goods was partly offset by a £7.6bn surplus on services.
Exports fell slightly, reflecting in part weaker demand in the eurozone.
Despite the sharp monthly increase, the deficit for the second quarter was, at £4.9bn, the smallest since the second quarter of 2011 and much lower than the £7.5bn deficit in the first quarter.
"Concerns about manufacturers being hammered by a stronger sterling and flat eurozone demand may have been premature, although encouraging as this may be, one decent quarter doesn't necessarily signal that big contributions to [economic] growth from net trade are around the corner," said Lee Hopley, chief economist at manufacturing group EEF.
"Indeed, the Bank of England's cautionary tone on world trade growth in its Inflation Report suggest there are still downside risks a-plenty."
Total goods exports in June totalled £24.9bn, while goods imports rose to £34.1bn.
The US was the UK's biggest export market, worth £4.4bn in June, followed by Germany, at £2.7bn. France, the Netherlands, the Irish Republic and China are the next biggest export markets.
The UK imported goods and services worth £5.34bn from Germany in June, more than from any other country. China, the Netherlands, the US and France are the next biggest source of imports.
The UK trade deficit almost doubled in June to £1.6bn, from £885m the previous month, the Office for National Statistics (ONS) has said.