Image copyright Getty Images

Germany's economy shrank during the April-to-June period of this year.

A decline in exports dampened growth, according to official data, which comes amid concerns of a global slowdown.

Gross domestic product (GDP) fell by 0.1% compared with the previous quarter, according to the Federal Statistics Office.

That takes the annual growth rate down to 0.4%. Germany, Europe's largest economy, narrowly avoided a recession last year.

Early signs for the third quarter "look ominous", said Andrew Kenningham, chief Europe economist at Capital Economics. "Manufacturing business surveys for July were all gloomy.

"And while the services sector should continue to hold up better, there are some signs that the slump is spreading to the labour market."

Trade war woes

While the overall figures were negative, household and government expenditure increased, as did investment outside the construction sector.

Construction itself fell after an unusually good first three months, boosted by a mild winter.

But Chancellor Angela Merkel's government still believes the economy will grow slightly this year and does not think further stimulus is necessary.

"As the chancellor has already laid out, the government does not currently see any need for further measures to stabilise the economy - the fiscal policy of the German government is already expansive," a government spokeswoman said.

Economy Minister Peter Altmaier said Germany was not in a recession and could avoid one by taking the right measures.

Image copyright Getty Images Image caption The European Central Bank, led by Mario Draghi, may be tempted to cut rates or buy more bonds to stimulate the eurozone economy, which includes Germany

Analysis: Andrew Walker, economics correspondent

This is the downside of being an exporting powerhouse. When the international economic environment clouds over, you get rained on.

The German statistical office hasn't given a detailed breakdown, but they have confirmed that exports declined and did so by more than imports.

China is at the centre of the trade storms and it's also an important export market for Germany. So trade held the economy back, in contrast with consumer spending and investment in Germany which both rose.

The economy contracted back in the third quarter of last year, and the subsequent rebound was not all that powerful.

Looking ahead, one question is whether Germany will see another decline in the current quarter, which would make it a recession as the term is often defined.

Some recent surveys of business confidence have been decidedly downbeat so the "R" word is certainly a possibility.

That said, Germany could still avoid it, and even if not, the country would at least be going into recession with unemployment that is among the lowest in the world.

"The development of foreign trade slowed down economic growth because exports recorded a stronger quarter-on-quarter decrease than imports," the statistics office said.

The US-China trade war and the UK's departure from the EU, especially if it happens without a deal, are among factors affecting global economic confidence.

Last month, the International Monetary Fund cut its growth forecasts for the global economy for this year and next, citing US-China tariffs, US car tariffs and no-deal Brexit.

China's own economic slowdown has weakened demand for foreign goods. It is an important market for Germany, since it buys plenty of luxury cars.

Only the much larger economies of the US and China export more goods than Germany.

The results may make authorities consider more monetary stimulus, said Neil Wilson, chief market analyst for Markets.com.

Meanwhile, the European Central Bank has hinted it could cut interest rates to tackle a slowdown in the eurozone economy.

The ECB said last month that a weak manufacturing sector and uncertainty over Brexit and trade threatened to derail growth. It forecast rates at current or lower levels until mid-2020.