The deficit reduced from £166 billion in 2016 to £153 billion last year, research from the Scotch Whisky Association (SWA) shows.
Without Scotch whisky exports, that would have been 2.9 per cent worse, at more than £157 billion, the analysis said.
The latest figures show that in 2017 the value of exports of Scotch whisky increased by 8.9 per cent to a record high of £4.37 billion.
Single malt exports also continued to grow, up 14 per cent year-on-year to £1.17 billion.
SWA chief executive Karen Betts said: “More Scotch whisky is enjoyed across the world than America, Canadian and Irish whiskies combined.
“Our analysis of 2017 exports shows just how well the industry is doing in our 180 markets.
“This reflects the industry’s determination and hard work to take high-quality Scotch whisky to consumers all over the world.
“The UK trade deficit, currently £153 billion, would have been nearly 3 per cent greater without Scotch whisky exports.
“Likewise, Scotch plays a key role in the Scottish and UK economy, supporting thousands of jobs, including in rural parts of Scotland.
“Single malt continues to grow significantly, boosting again the value of our exports. There are signs too that the market for blended Scotch whisky is improving.
“This is a welcome indicator of future growth. Blended Scotch is the solid foundation on which our global export success has been built.
“As Brexit approaches, it’s important that the government supports Scotch whisky’s export success and ensures that access to EU and global markets is as good once the UK leaves the EU as it is today.
“This includes ensuring that Scotch whisky is properly protected through the geographical indication system.”