UK retail sales increased by 0.7% in July, ahead of expectations.
The Office for National Statistics (ONS) figures also showed that retail sales rose by 3.5% in the year to July.
ONS statistician Rhian Murphy said: "Many consumers stayed away from some High Street stores in July, but online sales were very strong, supported by several retailers launching promotions.
"Food sales remained robust as people continued to enjoy the World Cup and the sunshine."
On the three-month measure for May to July, sales rose 2.1%, the strongest three months since February 2015.
The sales growth comes despite continuing pressures on High Street stores and weakened household spending power as pay growth struggles to outpace inflation.
Clothing sales recorded their strongest year-on-year growth since December, also helped by sales promotions, the ONS added.
Total spending online continued to increase, to reach a new record proportion of all retailing at 18.2% in July 2018.
Meanwhile, online spending via department store websites also reached a record proportion of their total sales, at 18.2%.
Wage growth weak
Andrew Wishart, UK economist at Capital Economics, said that the robust retail sales for July suggested "some recovery in consumer spending is in the pipeline".
He said: "Of course, retail sales only account for about a third of total household spending, so the strength of spending on the High Street could be offset by households reducing their outlay elsewhere."
Analysis: Jonty Bloom, BBC Business correspondent
While the good weather may have distorted these figures by keeping people off the baking hot High Street and at home shopping on their computers instead, the remorseless advance of online shopping is hard to deny.
It now accounts for a record 18.2% of all spending in the UK, a rise on last year of more than 15%. That boom was helped in the last month by a splurge of promotions by online shopping sites that increased sales, including Amazon Prime Day.
But an interesting aspect of the figures is that this is not just about new burgeoning online giants snatching business away from the traditional High Street. Department stores are rapidly moving into this area, their sales online have increased by 35% in the last year, so almost twice as quickly as the average.
That reflects a trend of even the largest department stores becoming more like shop windows, with shoppers visiting them to see the range and choice available but then going home to order online.
"Admittedly, still-weak real wage growth will weigh on consumer spending," Mr Wishart added. "Nonetheless, the retail sales data provides reason to think that consumer spending growth could post a slightly improved performance in the third quarter."
Following the announcement, the pound was up 0.24% against the dollar at $1.2727.
Hamish Muress, currency analyst at OFX, said: "The reaction from the pound... has been muted, suggesting that the wider view of the UK economy is still bleak.
"With the chances of a no-deal Brexit scenario high, wage growth shrinking and inflation rising, the Bank of England may find it difficult to follow through on any previous notions of further interest rate hikes in the future.
"As long as this outlook remains, the pound will continue to be under sustained pressure."