Output expanded by 0.1 percent in the April to June period, according to the federal statistics agency, which had previously projected zero growth.
The economy was propped up by both private and public domestic demand, with spending by the state up by 2.3 percent.
Private spending rose 0.8 percent from the previous quarter as the end of Covid-19 restrictions brought more tourism and outdoor dining.
Europe’s biggest economy has been slowing as inflation soars, with Russia’s invasion of Ukraine sending energy and food prices through the roof.
READ ALSO: German economy stalls as recession looms
Germany has been highly reliant on supplies of Russian gas to meet its energy demands, but Moscow has slowly dwindled supplies since the start of the war.
The threat that Russia could cut deliveries completely has raised the possibility of shortages over the winter and brought Germany closer to rationing supplies, with a punishing impact on business.
Bundesbank president Joachim Nagel had warned in a recent interview that although the German economy held up well in the second quarter, new supply chain problems would “further darken the outlook for the second half”.
Particularly, if the energy crisis were to worsen, “a recession appears probable for the coming winter”.