It comes after retail sales suffered their sharpest fall in six months in June, contracting by 0.9% from a month earlier, although the ONS said poor weather rather than Brexit was to blame.

Compared with the same time last year, July sales growth increased to 5.9%. The latest reporting period accounted for the month following the EU referendum, covering the four-week period from July 3 to 30.

The weak pound is likely to have played a role in boosting sales, drawing tourists to the UK to buy luxury items like jewellery and watches, said Howard Archer, the chief UK and European economist for IHS Global Insight.

The Brexit vote has sent sterling into a tailspin, with the UK currency falling about 12% since the result was announced.

Sterling immediately rose 0.4% against the dollar on the back of the July retail figures, rising almost a cent and breaking through 1.31 US dollars.

Against the euro, the pound rose 0.2% to 1.15.

Average store prices, including petrol stations, dropped by 2% compared with a year earlier, and were down by 0.8% from June.

However, the value of online sales increased by 16.7% compared with last year and 1.2% from a month earlier.

All sectors saw sales growth last month, but consumers spent more at non-food stores rather than supermarkets.

Paul Morales, a retail specialist at Lloyds Bank Commercial Banking, said: "Consumer spending habits have not fallen as sharply following the referendum as had been forecast by some.

"That being the case, retailers will be hoping that the current good weather holds, and that the feel-good factor being created by the Olympics translates to further spending on food and drink and Games-related merchandise."

The better-than-expected figures are providing some hope for UK gross domestic product (GDP) in the months ahead.

"July's jump in UK retail sales is a major boost to third quarter growth prospects," Mr Archer said.

However, sustained growth will rely on other economic fundamentals, including employment and inflation rates.

"The concern remains that the fundamentals for consumers will soften appreciably over the coming months, thereby weighing down on spending. Consumers are likely to face less favourable purchasing power as inflation rises and earnings growth is limited by companies striving to limit their costs," Mr Archer added.