Sales were 7.4% higher than the same month last year, the fastest year-on-year growth since April 2002, Office for National Statistics figures show.
Online sales were at their strongest for five years, proving consumers remained eager to shop despite uncertainty over the potential fallout from Brexit.
ONS senior statistician Kate Davies said: "The strong figures this month have been boosted by several factors.
"Cooler temperatures in October boosted clothing sales as shoppers took their cue to purchase winter clothing, while the supermarkets benefited from Halloween.
"This has also coincided with the strongest growth in internet sales seen for five years."
The underlying pattern in the retail industry continues to show "strong growth" following the 34th consecutive period of three-month-on-three-month growth, the ONS said.
Average store prices, including petrol stations, fell by 0.7% in October compared with a year ago - the smallest decrease since July 2014.
The amount spent in the retail industry increased by 6.6% compared with October last year and was up by 2.1% compared with September, while the amount spent online increased by 26.8% compared with October last year and by 1.3% compared with September 2016.
Chris Williamson, chief business economist at IHS Markit, said: "UK retailers enjoyed a mini-boom in October.
"Sales volumes showed the largest gain for just over 14 years, but such spending is looking increasingly unsustainable as inflation is likely to rear its head in coming months and households are growing worried about their future finances."
Howard Archer, chief UK and European economist for IHS Global Insight, said: "This was a cracking performance, which was way above all expectations.
"Even allowing for some helpful special factors, October's surge in retail sales indicates that consumers were still prepared to spend at the start of the fourth quarter, thereby buoying hopes that GDP growth can continue to hold up well."
But he added: "A major concern for the economic outlook - and for retailers in particular - is that it looks inevitable that the fundamentals for consumers will progressively weaken over the coming months with inflation rising markedly due to the weakened pound and companies likely increasingly looking to hold down pay to limit their total costs."
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