JetBlue reached an agreement to acquire the discount airline Spirit Airlines for $3.8 billion, it said Thursday.

The deal comes after Spirit’s shareholdersrejectedan acquisition agreement with Frontier Airlines.

JetBlue revised its offer multiple times in an effort to sweeten the deal and pry Spirit away from Frontier.

The deal needs approval from antitrust regulators and Spirit’s stockholders.

JetBlue expects the deal to close no later than the first half of 2024.