Lufthansa has agreed a rescue deal worth €9bn (£8bn) with the German government that saves it from collapse.

The German airline has been severely affected by a decline in travel due to the coronavirus and closed its budget airline Germanwings in April.

The German government will take a 20% stake in the firm, which it intends to sell by the end of 2023.

But the deal still has to be approved by the firm’s shareholders and the European Commission.

As part of the rescue package, the German government will also inject €5.7bn in non-voting capital, which is known as a “silent participation”.

Part of these funds can be converted into an additional 5% equity stake, which would enable the government to veto any potential hostile takeover bids.

European markets rose on the news, with Lufthansa shares closing 7.5% higher, while Germany’s Dax jumped 2%. The Frankfurt-based index closed at its highest level since 6 March.

The Cac 40 index in France meanwhile rose 1.5%, and the pan-European Euro Stoxx 50 climbed 1.1%.

Global airlines group IATA has said it expects airline passenger revenues to drop by more than 40% this year and warned that more than 25 million jobs in aviation and related industries are at risk.

“The support that we’re preparing here is for a limited period,” said Germany’s Finance Minister Olaf Scholz at a press conference on Monday.

“When the company is fit again, the state will sell its stake and hopefully … with a small profit that puts us into a position to finance the many, many requirements which we have to meet now, not only at this company.”

The bailout deal is the result of weeks of talks between Lufthansa and the German government about financial aid and will help save up to 10,000 jobs.

The German government has set aside a fund of €100bn to help shore up companies struck down by the pandemic.

The airline had previously been operationally healthy and profitable with good prospects, but had run into trouble because of the coronavirus lockdown measures implemented by governments across the world.

Lufthansa decommissioned more than 40 aircrafts in April and said it would look to offload aircrafts in its other businesses, which include Austrian Airlines, Swiss and Eurowings.

The airline had warned that it does not expect demand for air travel to return for “years”.

Lufthansa is not the only national carrier that has needed to be rescued. On Sunday, the French and Dutch governments pledged a lifeline of more than €11bn in loans and guarantees to support Air France-KLM.

Lufthansa has the most passenger traffic in Europe, followed by Air France-KLM, according to aviation analysts, the Centre for Aviation.

The UK government has indicated that it is preparing its own plan to rescue large British firms.

Last week, the bailout plan, named “Project Birch”, was mentioned by Transport Secretary Grant Shapps in Parliament during a discussion about the survival of the aviation industry.