$26 billion is a terrible thing to waste. That's more than what NASA or the State Department spends in a year, and more than the annual foreign aid budget. Yet the taxpayers needlessly lost this much in the auto bailout.

Why "needlessly"? Because President Barack Obama could have kept General Motors and Chrysler running without losing money - had he not given the United Auto Workers special treatment.

Both the union and management mistakes pushed the automakers into bankruptcy. They were saddled with massive debts and product-quality problems, while the United Auto Workers raised labor costs above $70 an hour. The companies asked Washington for an outright bailout in 2009.

To his credit, Obama instead required GM and Chrysler to reorganize through bankruptcy. But the administration did not just finance the reorganization. It also insulated the UAW from the sacrifices unions usually make in bankruptcy. Three legal irregularities transferred tens of billions of dollars to the union.

First, union members got to keep most of their above-market compensation. Normally bankruptcy courts reduce union compensation to competitive rates. But the administration did not let that happen in Detroit.

The UAW agreed to cuts for new hires, while existing employees made only minor concessions. As the UAW told its members, the bailout meant "no loss in your base hourly pay, no reduction in your health care, and no reduction in pensions." GM still has higher labor costs than any of its foreign competitors. Even Steven Rattner, the president's former "car czar," admits that was a mistake.

Second, the UAW recovered a much greater part of its debts than other creditors. When they went bankrupt, the automakers owed tens of billions to a UAW benefit trust. The trust paid for UAW members to retire in their mid-50s with minimal out-of-pocket health-care costs for the rest of their lives. These debts had the same priority as other unsecured lenders, such as bondholders and trade creditors.

Bankruptcy law entitles similarly situated creditors to recover their debts at the same rate. The principle applies in corporate bankruptcies, but the administration ignored it.

Chrysler's unsecured creditors got nothing, while GM's unsecured bondholders recovered just 27 cents on the dollar. Legally, the union trust should have gotten the same amount. Instead the administration repaid the union nearly in full - which is why the UAW owns almost half of Chrysler. That money should have gone to the taxpayers.

Finally, General Motors spent $1 billion to top up the pensions of UAW members at Delphi. This is highly unusual. GM had no legal obligation to the workers of its bankrupt former parts subsidiary. It gave nothing to Delphi's non-union employees. Yet GM gave $1 billion of bailout funds to retired UAW members at a different company. That money did nothing to keep GM operating.

The administration has stonewalled investigators examining if it directed GM to make this payment. Key former members of Obama's Auto Task Force refuse to meet with the Inspector General. It is unclear why they would do this if they had nothing to hide.

In total these irregularities cost taxpayers $26.5 billion. These costs account for the entire net cost of the bailout. They also directly subsidized the UAW's above-market compensation. Taxpayers could have kept the automakers running, prevented layoffs, and broken even. That didn't happen, and only because the administration gave the union special treatment.

UAW members are naturally glad they avoided larger sacrifices, but that doesn't justify their bailout. The typical UAW member at GM still makes twice what the average private-sector worker does. Few other Americans can retire at 56 or get retirement health benefits on top of Medicare.

The government should not use the taxes all Americans pay to prop up union compensation, especially when the national debt is exploding. High pay is good, but it must be earned through productivity and hard work, not taken from others through taxes.

The administration spent twice as much subsidizing UAW pay as the Labor Department spends on job training programs. This spending did not serve a greater public good. Normal bankruptcy financing would have kept the automakers in businesses without losing money.

Obama didn't bail out the auto industry. He bailed out the United Auto Workers.

James Sherk is senior policy analyst in labor economics at the conservative Heritage Foundation. Todd Zywicki is a law professor at George Mason University. Readers can write to the authors in care of The Heritage Foundation, 214 Massachusetts Avenue NE, Washington, D.C. 20002.