The past year has been a great time for stocks and an even better time for airlines. But even with many major carriers solidly outpacing the S&P 500, two carriers stand alone in delivering massive shareholder returns. I'll take a look at how these carriers did it and what their turnarounds mean for the future of the industry.

Confidence reversal
Last summer, Air Canada (TSX: AC.B) was the last place a conservative investor would want to park their money. Amid questionable profitability, an inefficient cost structure, and a pension liability estimated at over $4 billion, Canada's flag carrier was seen as on the brink of bankruptcy, with its sub-dollar share price reflecting its situation.

But things started to go right for Air Canada as problems started getting solved one by one. A favorable arbitration ruling allowed for the airline to create a discount carrier to serve routes where mainline Air Canada's cost structure would prove unprofitable, a carrier later launched as Air Canada rouge.

In March, Air Canada won temporary relief from fully funding its pension plan, keeping this liability from immediately threatening the airline's solvency. In exchange, limits on executive pay were instituted, as well as prohibitions on share buybacks and dividends, but it was a small price to pay to remain solvent.

Over the following months, two strong earnings beats combined with a positive outlook on cost cuts drove shares higher. On top of that, recent estimates from an analyst at BMO Capital Markets put the pension liability at less than $1 billion, a significant improvement over the same period a year earlier.

What it means
With Air Canada's prospects far brighter today, shares have cracked the C$7 mark after a strong rally. But the airline's plans aren't finished. The pension relief and increased earnings power have given the airline more funds to invest in fleet modernization. Air Canada now has 37 Boeing 787 Dreamliners on order, and is reported to be studying ways to modernize its narrowbody fleet.

Further upside could still be in store if Air Canada can live up to earnings expectations for 2013 and 2014, respectively. Estimates shown by Businessweek call for C$1.04 EPS for 2013 and C$1.23 EPS for 2014. Applying a 10 times P/E ratio seen at many other major carriers creates double digit upside for Air Canada shares over the next year.

Buying a bankrupt airline
Historically, airlines have been seen as bad investments, and bankrupt companies as even worse ones. But this logic was turned on its head when AMR (NASDAQOTH: AAMRQ), parent company of American Airlines, went from being a bankrupt penny stock to a leveraged play on the merger that would create the world's largest airline.

When AMR declared bankruptcy back in 2011, it looked like game over for common shareholders. But AMR went bankrupt with nearly $4 billion in cash and no near-term debt maturities. In hindsight, it actually seems like AMR's bankruptcy was more about cost structure improvement than true insolvency.

Helping to create value for AMR common shares was the persistent takeover interested shown by US Airways (NYSE: LCC), which eventually crafted a deal where the two airlines would merge through an agreement allocating a fraction of new shares to AMR common shareholders.

Shares of AMR took off out of the sub-dollar range and climbed into the $5-$7 range in anticipation of the merger. After a temporary plunge following an antitrust lawsuit by the Department of Justice, shares began to regain ground on the possibility of a settlement. Sure enough, a settlement was reached, and the increased price of US Airways shares pushed AMR shares into the $12 range.

What it means
The revival of bankrupt AMR's common stock is perhaps the biggest surprise in the airline industry in several years. But the merger of US Airways and American Airlines is bound to shape the industry for years to come. This merger completes the consolidation of legacy carriers, as it would be next to impossible for United Continental (UAL 1.59%), Delta Air Lines (DAL 4.05%), or American to merge with each other.

Going forward, all legacy carriers stand to benefit from this consolidation, as it creates greater pricing power for airlines and makes capacity management more effective. Additionally, the successful merger of US Airways and American Airlines eliminates the possibility that a stand-alone American Airlines would attempt growth through large capacity increases.