The German economy unexpectedly shrank in the second quarter, preliminary data showed Tuesday, falling further behind as a recovery takes hold elsewhere across the eurozone.

Output in Europe's biggest economy contracted by 0.1 percent compared with the previous three months, federal statistics office Destatis said, after expanding by 0.2 percent in the first quarter.

The second-quarter data surprised analysts surveyed by FactSet who had forecast a 0.1-percent increase.

The April-to-June period noticeably saw declining investment in equipment and construction, Destatis said.

"The German economy is stuck in crisis," said Klaus Wohlrabe from the Ifo economic institute, citing persistent weakness in manufacturing and sluggish private consumption.

"Hardly any improvement is to be expected in the third quarter of 2024 either," he added.

Germany, traditionally a driver of European growth, was the only major advanced economy to shrink in 2023 as it battled high inflation, an industrial slowdown and cooling export demand.

A string of indicators had suggested a recovery was getting under way at the start of the year, but hopes of a strong rebound have been tempered by weaker data in recent weeks.

"Germany is performing very poorly at the moment, especially in comparison with neighbouring European countries where we have seen quite robust growth figures," said LBBW economist Jens-Oliver Niklasch.

"Of course, Germany's export-orientated industry is more exposed to the weakness of the Chinese economy, for example, but many of the problems are homemade," he added.

A shortage of skilled labourers, burdensome red tape, a costly green energy transition and years of under-investment in infrastructure are all adding to Germany's woes.

The comparison with other eurozone heavyweights was stark on Tuesday, with the French economy rising by a more-than-expected 0.3 percent in the second quarter.

The Spanish economy also beat forecasts, growing 0.8 percent on the back of higher exports and strong household spending.

Overall, output in the 20-nation eurozone expanded 0.3 percent over the second quarter, more than the 0.2 percent expected by analysts.

- 'Laggard' -

Chancellor Olaf Scholz's government sees the German economy growing by 0.3 percent this year, buoyed by rising consumer spending as inflation eases further and interest rates come down.

German's July inflation data will be published later on Tuesday, after easing to an annual rate of 2.2 percent in June.

The European Central Bank will be closely watching the latest inflation and growth data as it weighs whether to cut rates again in September, after lowering borrowing costs for the first time since 2019 last month.

"All in all, today's data once again confirms that Germany is the growth laggard of the eurozone," said ING economist Carsten Brzeski.

But he added that "a rebound in the second half of the year is still possible, even though it is highly unlikely that it will be a strong one".