The German economy grew a better-than-expected 1.9 percent last year, official data showed Friday, as government relief measures cushioned Europe's export giant from an energy crisis triggered by the war in Ukraine.

The expansion was slower than the 2.6 percent growth in 2021, with GDP "stagnating" in the fourth quarter as inflation surged following Russia's invasion of Ukraine, statistics authority Destatis said.

But 2022 growth surpassed the 1.8 percent forecast by analysts, as government interventions and a mild winter helped Germany weather sky-high energy costs seen after Moscow slashed crucial gas supplies to Europe.

It was also higher than the 1.4 percent expansion forecast by the government last October.

Analysts and the government have been predicting that Europe's largest economy will fall into recession this year, but the GDP figures -- and a string of recent indicators -- suggest it may dodge a severe downturn.

"Through decisive actions in the past year, we made the crisis manageable," Economy Minister Robert Habeck said in response to the growth data.

"In a short space of time, we pushed through legislative packages and mobilised large sums of money to support the economy and unburden consumers," he said.

But Destatis president Ruth Brand outlined the challenges faced by Germany, from "extreme energy price increases" to supply chain bottlenecks, rising food prices and a shortage of skilled workers.

"Despite these difficult conditions, the German economy held up well overall in 2022," she added.

Fritzi Koehler-Geib, chief economist at the public lender KfW, said the growth data was a "respectable result, made possible by the stabilisation policy of the German government and the adaptability of many companies."

"Nonetheless, the macroeconomic losses were still considerable: Before Russia's assault on Ukraine, growth was expected to be roughly twice as high," she said.

- 'Stagnating, not contracting' -

Moscow's reduction of gas supplies via pipeline to Germany upended Berlin's long-held business model -- importing cheap Russian energy to power its flagship industrial sector and export high-quality goods to the world.

The government was left scrambling to find new -- and more costly -- sources of energy as food and fuel prices soared, weighing on German industry and consumers.

But efforts to build up gas reserves in preparation for the winter have allowed Germany to skirt acute shortages.

A massive 200-billion-euro ($216 billion) support package announced in September to limit household energy bills and support businesses has also taken the sting out of price rises, analysts say.

The government itself had forecast in October that the economy would shrink 0.4 percent over the whole of this year.

But a string of indicators, which for months flashed red, are now turning around and suggest that the downturn will be less severe than initially feared.

Some analysts warn the reprieve may prove temporary given significant risks that lie ahead.

Germany will likely be unable to dodge a recession -- two consecutive quarters in which the economy shrinks -- said Carsten Brzeski, head of macroeconomics at ING.

The 2022 GDP figure "implies a stagnating, not contracting, economy in the fourth quarter. Will the widely predicted recession simply fail to materialise? We remain doubtful," he said.

"Avoiding the worst does not suggest the economy is doing well," he added.

Germany's public deficit came in at 2.6 percent of GDP last year, Destatis also reported, but the finance ministry has forecast it will widen to 3.25 percent this year due to the massive outlays to combat the energy crisis.