By Wiktor Szary and Jason Douglas

LONDON--U. K. retail sales grew at the fastest annual pace in nearly 15 years in October, official data showed on Thursday, as British shoppers snapped up hats and coats and Halloween treats, remaining defiant in the face of stirring inflation and a widely anticipated slowdown in the job market.

October sales grew by 7.4% compared with the corresponding month last year, the Office for National Statistics said, significantly above the expectations of analysts polled by The Wall Street Journal, who forecast 5.3% growth. Compared with September, sales rose by 1.9%, also significantly beating economists' expectations.

The robust growth was driven by cooler October temperatures, which prompted Britons to buy winter clothing, and by stronger-than-usual Halloween sales at supermarkets.

Internet sales also grew strongly, rising at the fastest annual pace in over five years. The surge may have come partly from abroad, as foreigners took advantage of the favorable exchange rate, said Alan Clarke, head of European fixed-income strategy at Scotiabank.

Overall, the retail sales "boom" may have also been triggered by Britons rushing to the shops "in anticipation of higher prices tomorrow," Mr. Clarke said. Many economists worry that accelerating price growth combined with a widely predicted tightening of the labor market may in the coming months curb Britons' willingness to part with their money.

Inflation slowed slightly in October after it hit a two-year high the previous month, but manufacturers' input prices rose at the fastest monthly rate of growth on record, driven by the pound's post-referendum slip. The Bank of England expects this will translate into a rapid pickup in consumer prices next year, with inflation exceeding the BOE's 2% target by mid-2017.

Britons got a taste of what is likely to come when the maker of the Toblerone chocolate bar, Mondelez International Inc., recently decided to lengthen the gaps between the bar's "peaks," citing rising production costs. Other manufacturers, including Hellmann's mayonnaise maker Unilever PLC, have raised prices here recently, citing sterling's weakening.

Whether Britons carry on spending in the face of rising prices will be critical to how well the world's fifth-largest economy performs in the months and years ahead as the country charts its departure from the European Union.

Britain's June 23 vote to leave the bloc initially triggered the steepest dive in consumer confidence in a generation, but sentiment has recovered since. Retailers enjoyed a solidsummer, as sales were boosted by warm weather as well as the weakened pound, which lured overseas tourists into British shops.

Write to Wiktor Szary at Wiktor.Szary@wsj.com and Jason Douglas at jason.douglas@wsj.com

(END) Dow Jones Newswires

November 17, 2016 07:00 ET (12:00 GMT)

Copyright (c) 2016 Dow Jones & Company, Inc.