BERLIN (AP) — The German economy grew in the third quarter, an unexpectedly positive performance powered largely by private spending, official figures showed Friday. But the immediate outlook for Europe’s biggest economy remained gloomy, with inflation rising again in October.

Gross domestic product expanded by 0.3% in the July-September period compared with the previous quarter, the Federal Statistical Office said. That followed a slight increase of 0.1% in the second quarter.

“The German economy managed to hold its ground despite difficult framework conditions of the global economy, with the continuing COVID-19 pandemic, supply chain interruptions, rising prices and the war in Ukraine,” the statistics office said.

The government said earlier this month that GDP was believed to have shrunk in the third quarter and was expected to decline again in the last three months of the year as well as the first three months of 2023 before beginning to recover. Two consecutive quarters of negative growth is one technical definition of recession.

With energy prices high, Germany — like many other countries — is grappling with skyrocketing inflation. The annual inflation rate rose once again in October, climbing to 10.4% from 10% the previous month, according to a preliminary estimate released by the statistics office on Friday.

On Tuesday, a survey showed German business confidence stuck at its lowest level in more than two years as energy worries fuel expectations of a difficult winter.

Lawmakers last week cleared the way for the government to provide up to 200 billion euros ($195 billion) in subsidies to households and businesses through 2024 to ease the strain of high energy prices, and parliament’s upper house added its approval on Friday. However, details of that plan haven’t yet been finalized.

Officials say Germany is well-placed to get through the winter with sufficient energy after Russia cut off natural gas supplies but stress that it will still need to conserve the fuel that heats homes, powers factories and generates electricity.

“Looking ahead, the surprise growth in the third quarter does not mean that the recession narrative has changed,” ING economist Carsten Brzeski said. “All leading indicators point to a further weakening of the economy in the fourth quarter and there doesn’t seem to be any improvement in sight.”

“Pent-up demand and savings from past lockdown periods provided sufficient counterweight to the dampening influence of sharply rising inflation, thus delaying the start to the recession that we nonetheless continue to expect during the next two quarters,” said Timo Klein, an economist at S&P Global Market Intelligence.

In a speech Friday, President Frank-Walter Steinmeier told Germans that “we face harder years, rough years” in a more confrontational world. “The peace dividend has been used up.”

Steinmeier, whose post is largely ceremonial but holds moral authority, pointed to Germany’s economic strength and its efforts to ease the financial strain on its people, but said “even our state won’t be able to compensate for every burden.”

“It is clear that we will have to put up with constraints in the coming years,” he said.