American Airlines is flying in the big leagues now.

The company is doing so well that its stock will join the prestigious S&P 500 after the market closes Friday, replacing pharmaceutical company Allergan (AGN) in the index that tracks 500 of America's largest brands.

It's quite a turnaround for a company that filed for bankruptcy in 2011 and spent much of the past few years in court.

America Airlines (AAL) stock bounced 7% on Tuesday and is trading near an all-time high.

It may be St. Patrick's Day, but this isn't the luck of the Irish. It's the result of consolidation.

The airline business has altered substantially as carriers have combined fleets in recent years. American merged with U.S. Airways in 2014 to create the biggest airline group in the world.

Related: Airlines mergers and bankruptcies

The timing couldn't have been better. As the economy improves, more and more people are flying for business and pleasure. Planes are booked full again and there has been little pressure to lower ticket prices.

On top of that, airlines are enjoying massive savings from the plunge in fuel prices since the summer. American Airlines forecasts $4.5 billion in fuel savings this year.

These factors made 2014 American Airlines' first profitable year since 2007.

Related: Why flying stinks, and you're still paying more

"We certainly knew we would be in the S&P 500 at some point in time, but this is earlier than most people expected," American Airlines CEO Douglas Parker told CNBC Tuesday.

Airlines were once seen as "buy at your own risk" stocks because of their history of bankruptcies and problems. Now they are by and large doing well.

Rivals Southwest (LUV) and Delta (DAL) were some of the top performers in the S&P 500 last year.

American's stock is enjoying a nice bounce from entering the S&P 500. Many funds track that index, so getting in the index forces funds to buy the stock, sending the price higher.

Whether that liftoff continues for rest of the year remains to be seen. While fuel prices and full planes help the bottom line, there's concern in the industry about the plans of Middle Eastern airlines such as Emirates, Etihad and Qatar Airways, all of which hope to grow in the U.S.

That competition could be a big headwind to America's domestic airline industry, which finally seemed to have found smooth skies.