DUBAI, United Arab Emirates (AP) — The Middle East's largest airline, Emirates, is throwing Airbus a lifeline for its troubled A380 jumbo jet.

The carrier said Thursday it struck a deal with Airbus to buy 20 of its A380 double-decker jets, with the option to buy 16 more, in a deal worth $16 billion.

Airbus had said earlier this week that if it didn't close the deal with Emirates, it would end production altogether of the jet. The plane has been difficult to sell in part because of its unusually large size, which can be hard to fill and requires bigger runways.

"This new order underscores Airbus' commitment to produce the A380 at least for another ten years," said Airbus chief salesman John Leahy.

The deal removes one thorn in Airbus's side as it struggles with a series of production problems and legal woes. Authorities in Britain and France are investigating alleged fraud and bribery related to Airbus' use of outside consultants in commercial plane sales. Airbus has warned the investigations could lead to "significant penalties."

In an effort to get past these problems, the company in December shook up its top leadership, announcing that its CEO, Tom Enders, will step down in 2019.

The deal with Emirates also caps several weeks of talks and tensions with the airline.

In November, Airbus suffered the embarrassment of believing it had struck a deal to sell A380s to Emirates, only to see Boeing sit on the podium with the airline and sign a $15.1 billion deal.

Dubai-based Emirates already has 101 A380s in its fleet and 41 more on order, making it the largest operator of the jumbo jet. Its fleet relies solely on the Airbus 380 and the Boeing 777.

Emirates Chairman and CEO, Sheikh Ahmed bin Saeed Al Maktoum, said at a signing of the deal in Dubai that the order "will provide stability to the A380 production line."

Emirates, which is owned by the Dubai government in the United Arab Emirates, said the additional A380s will be delivered to the airliner from 2020 onwards and that some of the new A380s will be used as fleet replacements.

An Airbus A380 has a list price of $445.6 million, but airlines and manufacturers often negotiate lower prices. Airbus delivered just 15 of the planes last year, and aims to deliver 12 more this year.

Leahy had said Monday that Emirates is the only airline with the ability to commit to a minimum of six planes a year for a minimum of eight to 10 years, or what is needed to make the Airbus program viable.

"It's positive news for both sides," said airline analyst John Strickland of JLS Consulting. "The A380 is critical to Emirates' hub-and-growth strategy and equally the airline is key to Airbus' continuation of the program. It will be a great relief to Airbus to have secured this order, but they have to work aggressively to secure orders from other airlines too now."

Dubai ruler Sheikh Mohammed bin Rashid Al Maktoum said the deal reflects Emirates' commitment to advancing "Dubai's vision to grow further as a world-class destination and aviation hub." Dubai's main airport, where Emirates is based, is among the busiest in the world with more than 80 million travelers passing through in 2016.