BERLIN, May 23 (Reuters) - The German economy is on track for a tepid economic recovery but risks are tilted to the downside and Berlin should focus on cushioning the impact of the war in Ukraine and on securing gas supplies, the International Monetary Fund said on Monday.

Fiscal policy in Europe's largest economy should be flexible in an uncertain environment, the IMF added in a statement after a mission to Germany.

The IMF said it projected that growth in the German economy would slow to about 2% in 2022, picking up in 2023 to slightly above 2% if energy prices and supply bottlenecks subside, and COVID-19 infections remain under control.

"Growth would then decline toward potential after 2024," the IMF said in its so-called Article IV report.

"Output would remain below the pre-pandemic trend in the medium term, given headwinds from elevated energy prices to private investment, weaker external demand, and greater economic and geopolitical uncertainty following the war," it added.

Berlin's immediate policy priorities must be to secure supplies of gas, cushion the spillovers from Russia's invasion of Ukraine, and build up resilience, the IMF said.

The uncertain outlook for fossil fuel supplies makes the government's plan to fast track a green transition even more critical, it added.

The greatest threat to the outlook is a persistent and complete shut-off of Russia's gas exports to Germany and Europe more broadly, it said.

The IMF said that if downside risks materialize, the government should "continue to flexibly provide targeted support, and consider activating the escape clause of the debt break rule for another year."

Germany's so-called debt brake, which stipulates that the federal and state budgets must generally be balanced without revenues from borrowing, was temporarily suspended due to measures related to the COVID-19 pandemic.

Finance Minister Christian Lindner is aiming to comply with the debt brake again in 2023. (Writing by Paul Carrel, Editing by Miranda Murray and Hugh Lawson)