An American Airlines plane takes off from the Miami International Airport on May 02, 2023 in Miami, Florida.

American Airlines pilots approved a sweetened labor deal, making the carrier the second major U.S. airline to seal a new contract with its highest-paid work group.

The more than 15,000 pilots at American will get immediate raises of 21% with compensation increasing more than 46% over the duration of the four-year contract, including 401(k) contributions, their union said Monday. They will be due a 5% raise next year, followed by 4% in 2025 and 2026, followed by a 3% increase in 2027.

Pilots have been pressing airlines for better compensation and work rules as the industry faces a shortage of aviators in the wake of the Covid pandemic. That crisis derailed negotiations, preventing many workers across the airline industry from getting contracted pay increases, while inflation soared.

An earlier deal between American and the union fell apart after rival United Airlines and that carrier's union reached a richer, preliminary deal. But American increased its offer last month.

American's pilots voted more than 72% in favor of the new contract, and there was a 95% turnout, according to the Allied Pilots Association. The agreement also includes improvements in scheduling and benefits.

American said on Tuesday retroactive pay for the pilots will cost it $230 million in the third quarter. The airline raised its unit cost guidance on Tuesday to a 4% to 6% increase compared with the same period last year, up from a previous forecast of a 2% to 4% increase, maintaining its annual guidance.

"This agreement will help American immediately expand our pilot training capacity to support under-utilized aircraft and future flying and provide our pilots with more opportunities to progress in their careers," American's CEO, Robert Isom, said in a statement.

Delta Air Lines pilots ratified a new agreement earlier this year.