Germany's coalition government has agreed to plug a 17-billion-euro ($18.32 billion) hole in its budget for 2024 by cutting climate-damaging subsidies, spending in some ministries and federal grants, Chancellor Olaf Scholz said on Wednesday.

The deal, reached after a weeks of crisis talks, will enable Germany to stick to its self-imposed debt restrictions, Scholz said in a press statement, flanked by Economy Minister Robert Habeck and Finance Minister Christian Lindner.

Should the situation in Ukraine, fighting off a Russian invasion, worsen, then Germany could declare an emergency situation in order to suspend the so-called debt brake and increase funding to Kyiv, Scholz said.

"The government will stick to its goals ... but we must do so with less money which means cuts and savings," he said. "Such difficult budget talks usually last months, but we carried them out within a few weeks." ($1 = 0.9278 euros) (Reporting by Miranda Murray, Madeline Chambers and Sarah Marsh, Editing by Rachel More)