Correction: An earlier version of this article incorrectly listed the first name of US Airways executive Doug Parker as well as the name of the company that merged to form that airline. It is America West. This version has been updated.

Over the past decade, major airlines have figured out how to use the bankruptcy code to accomplish what they have never been able to at the bargaining table: reduce wages and benefits to “market” levels.

Back in the days when fares and routes were regulated by the government and compensation was effectively set in an industry-wide pattern, there wasn’t much incentive for airlines to resist above-market wages, gold-plated benefits and inflexible work rules. And even after the industry was deregulated and the major carriers faced competition from lower-cost, non-union upstarts, the threat of a crippling strike gave the airline unions the upper hand in contract negotiations.

Bankruptcy has changed all that. Suddenly, airline executives discovered a way to unilaterally abrogate their labor agreements, fire thousands of employees and impose less generous pay and more flexible work rules. Indeed, the technique proved so effective that several airlines went through the process several times. The unions’ strike threat was effectively neutralized.

All of which makes what is happening at American Airlines deliciously ironic. Late last year, American finally decided to join the rest of the industry and make its first pass through the bankruptcy reorganization process after failing to reach agreement on a new concessionary contract with its pilots’ union.

The company hoped to win speedy court approval for a plan to eliminate 13,000 positions, reducing benefits to current employees and retirees and reforming work rules that have made American’s productivity the lowest in the industry. Instead, the unions did an end run and struck new labor agreements with US Airways, which will use it as the basis for launching a bid to buy its larger rival out of bankruptcy.

If the gambit succeeds, the unions will not only wind up with more jobs and higher pay than American was offering, but also the satisfaction of seeing American’s top executives tossed out on the street.

It’s taken the American unions — particularly the pilots unions — far too long to acknowledge how far out of whack their compensation had become compared with the rest of the labor market. This is still an industry, after all, in which senior pilots work the equivalent of 12 to 15 days a month while earning pay and benefits valued at $200,000 to $250,000. The rules governing compensation and scheduling remain so arcane that two Northwest Airlines pilots recently flew their plane 45 minutes past their destination in Minneapolis because they were so engrossed in trying to game the system to get the flight assignments they desired. Even today, seven years after the merger of America West into US Airways, the two pilots unions are still in court fighting over how to merge their seniority lists.

All of which makes the pilots union deal with US Airways so significant. Essentially, US Airways agreed to pay all of its pilots — the American pilots as well as its own — the higher American Airlines wages, along with small annual raises. In return, the union accepted less lavish medical and retirement benefits along with adoption of US Airways work rules that have been rationalized during two trips through the bankruptcy process. In the end, what probably sealed the deal was the US Airways promise of no layoffs.

How can US Airways afford to do all that while remaining competitive? The answer lies partly on the cost savings it expects to realize through the new labor contract and the efficiencies realized by combining two airlines into one. Just as significant, however, will be the additional revenue that US Airways anticipates as the “new” American begins to win back profitable corporate accounts it lost over the past decade as it failed to grow its route network.

In short, while the turnaround plan offered by American’s management relies solely on $800 million in annual cost cutting, mostly in the form of labor savings, the merger with US Airways is premised on $1.2 billion in synergies that result in large part from increased revenue as the merged carrier achieves the scale and scope necessary to compete with industry leaders United and Delta.

Dave Bates, the president of the American pilots union, also makes clear that his members were making a conscious choice to turn against a “dysfunctional” American management team. Bates contrasts the approach taken by American, which invariably sent flunkies to the negotiating table to posture and threaten and quibble over five years of fruitless talks, with US Airways and its “lean, energetic and highly-capable” management team. He noted that US Airways top executives, Doug Parker and Scott Kirby, got directly involved in face-to-face bargaining and that they were able to hammer out the outlines of a new contract in a little more than a week.

The new message from the airline unions is that both sides can play the bankruptcy game. It certainly helps that, in the case of American, the unions start out with three seats on the nine-member creditor committee and are working with a team of Wall Street advisers that includes investment bankers from Lazard Frere and lawyers from Steptoe & Johnson.

The unions also appear to have the tacit support of the federal government, in the guise of the Pension Benefit Guarantee Corp., which figures having a stronger, merged airline will make it less likely the PBGC will have to step in and rescue the underfunded pension plans. And certainly it has not gone unnoticed by other creditors that the value of American’s outstanding bonds, which had fallen to 30 cents on the dollar, has climbed to 50 cents since the union deal with US Airways was announced.

A marriage of American and US Airways is the final piece of consolidation necessary to put the airline industry on sustainable financial footing after nearly three decades of over-expansion and hyper-competition that undermined profitability.

With the mergers of Delta with Northwest, and United with Continental, No. 3 American now finds itself falling well behind on the all-important metric of revenue per seat for every mile flown. The reason: insufficient feeder traffic into its hubs from secondary cities. A merger with US Airways would move American from an also-ran in the East Coast and Midwest markets into first place, with an even more dominant position in its Miami gateway to South America and a chance to go toe-to-toe with United in Chicago.

In the past, US Airways attempts to find a partner have run afoul of the antitrust police. Given the lack of overlapping hubs, that’s not likely to happen this time. The only place where the combination is likely to run into problems is at Reagan National Airport, where the two carriers account for about two-thirds of the traffic. The new American would almost surely be forced to sell off gates and landing slots, making room for more head-to-head competition from Southwest and Jet Blue. Good news, in other words, for Washington travelers.

It will take a few more months of legal maneuvering before American finally throws in the towel and agrees to a US Airways merger. American executives and directors will no doubt have to be bought off with golden parachutes, while trade creditors such as Hewlett-Packard and Boeing will likely be brought on board with promises of future contracts. That’s how things work in the bankruptcy racket. And all of it will be negotiated behind closed doors by legions of bankruptcy lawyers whose $1,000-an-hour fees make those $250-an-hour pilots look like pikers.

For years now, Corporate America has viewed the bankruptcy court as a blunt instrument by which failed executives and directors can shift the burden of their mistakes onto shareholders, employees and suppliers. The auto industry bailout orchestrated by the Obama administration posed the first challenge to that assumption. Now the unions at American airlines have taken another step in curbing this flagrant corporate abuse and restoring the rule of law.