The UK economy contracted 0.2% between April and June, its worst performance since 2012, the Office for National Statistics said.
The surprise contraction came after a boost to economic growth in the first three months of the year because of Brexit stockpiling.
Rob Kent-Smith, head of GDP at the ONS, said manufacturing output fell and the construction sector weakened.
The pound slipped after the data was released, raising fears of a recession.
A recession occurs when the economy contracts in two consecutive quarters.
“Manufacturing output fell back after a strong start to the year, with production brought forward ahead of the UK’s original departure date from the EU,” said Mr Kent-Smith.
He added that “the often-dominant service sector delivered virtually no growth at all”.
Economists had not been forecasting a contraction in the economy in the second quarter but had expected it to stagnate, with the consensus forecast for 0% growth.
The economy had shown 0.5% growth in the first quarter after manufacturers’ stockpiling ahead of Brexit helped to boost output.
The ONS said: “The path of GDP and some of its components has been particularly volatile through the year so far, largely reflecting changes in timing of activity related to the UK’s original planned exit date from the European Union in late March.”
The economy has contracted over a quarter for the first time since 2012, raising the risk that the UK might be in a technical recession.
The numbers do contain some distortions that flattered growth in the first quarter, and have depressed it in the second, including stockpiling for a no deal Brexit.
They also contain the post no deal shutdowns of car factories around the first Brexit deadline in March.
But there are some real and enduring weaknesses in this number too, some of which is down to poor levels of investment, and some down to poor global growth.
This figure though is set to be the worst in the G7. The UK should avoid a recession if expectations of growth in this quarter are fulfilled, but that is not guaranteed. It is not the welcoming present that a new chancellor and PM would have wanted.
The ONS said the latest figures showed that the increased stock levels had been partly run down in the second quarter and that a number of car manufacturers had brought forward their annual shutdowns to April as part of contingency planning.
The data comes at a time when there are signs other economies are slowing. For instance, data on Friday showed that French industrial output also fell more than expected in June.
The employers’ body the CBI said the contraction was “concerning”.
Alpesh Paleja, CBI Lead Economist, said: “Growth has been pushed down by an unwind of stockpiling and car manufacturers shifting their seasonal shutdowns.
“Nonetheless, it’s clear from our business surveys that underlying momentum remains lukewarm, choked by a combination of slower global growth and Brexit uncertainty.
“As a result, business sentiment is dire.”