The UK economy showed a surprisingly good performance in the second quarter of the year, rising 0.5 per cent in June.
Economists had expected GDP to grow by 0.2 per cent in June and remain static in the quarter as a whole. It grew by 0.1 per cent in the first quarter of the year.
It means that quarterly GDP is still 0.2 per cent below where it was in the final three months of 2019, before the Covid-19 pandemic forced the country into lockdown.
Businesses told the ONS that their output had increased in June to make up for the extra bank holiday in May.
ONS director of economic statistics Darren Morgan said: “The economy bounced back from the effects of May’s extra bank holiday to record strong growth in June. Manufacturing saw a particularly strong month with cars and the often-erratic pharmaceutical industry seeing particularly buoyant growth.
“Services also had a strong month with publishing and car sales and legal services all doing well, though this was partially offset by falls in health, which was hit by further strike action.
“Construction also grew strongly, as did pubs and restaurants, with both aided by the hot weather.”
Returning the economy to good health is one of Prime Minister Rishi Sunak's five key goals.
Chancellor Jeremy Hunt said: “The actions we’re taking to fight inflation are starting to take effect, which means we’re laying the strong foundations needed to grow the economy.
“The Bank of England is now forecasting that we will avoid recession, and if we stick to our plan to help people into work and boost business investment, the IMF (International Monetary Fund) have said over the longer-term we will grow faster than Germany, France and Italy.”
Alice Haine, personal finance analyst at DIY investment platform Bestinvest, said: "The UK economy has remained surprisingly resilient so far this year despite the challenges to output posed by interest rate increases, high inflation, widespread industrial action and a deepening cost-of-borrowing crisis.
"While the country may still dodge a recession in 2023 – as defined by two successive quarters of contraction – the slight rise in economic activity in June masks the troubles ahead.
"With interest rates now at their highest level since the 2008 financial crisis and likely to rise again from here, food and energy costs still elevated, inflation only now easing from the persistently high level seen over the past year and the tax burden at the highest level since the Second World War, households and businesses are struggling under the weight of cost pressures."
The statisticians found that the human health and social work sector affected GDP in June, shrinking by 0.8 per cent. There were four days of strikes by junior doctors during the month, although nurses did not strike.
Ben Jones, CBI lead economist, said: “With fiscal and monetary policy expected to remain tight for the foreseeable future, we need a renewed focus on building the productive capacity of the economy, which is the surest way to drive up growth and living standards in the UK.”
Mr Jones further suggested that affordable reforms to the tax and regulatory landscape are essential, which would empower businesses to invest and transition towards greener initiatives with greater assurance.
Matt Britzman, equity analyst at Hargreaves Lansdown, said: "The numbers push the chance of a recession further down the line, but the UK economy looks firmly stuck in a low growth cycle, and with further interest rate hikes firmly priced in by the markets there doesn't look to be an immediate path out.”
The new data puts the UK on a better course to avoid falling into a recession, which is defined as two quarters in a row where GDP shrinks.
But forecasts from the Bank of England foresee growth staying sluggish for years to come.