DETROIT -- When the word reached the Orion Assembly Plant, it spread along the serpentine assembly line like news of a death or natural disaster: General Motors, the biggest automaker in the world, had filed for bankruptcy protection.On that grim day in 2009, Chevrolet and Pontiac sedans kept rolling down the line. And 1,700 worried workers stayed at their stations even as GM announced it would close the plant in a desperate bid to survive."The unknown was the scariest part," recalled Gerald Lang, who had worked at Orion for two years installing dashboards and doors. "We really had no clue what was going to happen."There was something else that the workers didn't know: They were witnessing the opening act of one of the greatest recovery stories in American business.Nearly four years later, Chevrolets are still moving down the assembly line under the plant's 82-acre roof. Lang and his co-workers now build the Sonic, the bestselling subcompact car in the nation. It's a vehicle no one thought could be made profitably in the U.S., by a company that few people thought would last.But GM has not only survived, it has earned $16 billion in profits in the past three years. And the industry is on track to make this year its best year since 2007.Detroit's improbable comeback is the work of many: President George W. Bush, who authorized the first bailout loans; President Barack Obama, who made more loans; workers who took lower wages and focused more on quality to compete with foreign rivals; and executives and designers who developed better cars amid the financial maelstrom happening around them.To be sure, there were victims: shareholders, auto-parts makers and other suppliers who went out of business, as well as taxpayers who will never get all their money back.But there is no denying that American carmakers have made a remarkable recovery. Nearly 790,000 people now have jobs building cars, trucks and parts, up 27 percent from the dark days of 2009. In Arlington, GM has hired 1,000 workers in recent months as part of a $530 million expansion of its assembly complex that is adding a stamping plant and a third shift to manufacture large sport utility vehicles. In addition to 3,500 workers in Arlington, GM employs another 1,850 people in Tarrant County in its Fort Worth-based GM Financial unit.The story of the Sonic shows how the industry, along with a community in a downtrodden state, got there.Downward spiralThe collapse of the industry in 2008 that nearly put GM and Chrysler out of business and cost Ford billions of dollars came from a perfect storm that included the Great Recession, expensive gasoline and the financial meltdown that dried up funding for car loans. But the automakers' problems were years in the making.They had business models that couldn't generate enough cash to cover expenses. They had too many factories making too many cars and trucks. They sold too many vehicles at discounts or even steep losses just to move them out of showrooms to make room for more. And their workers earned more in wages and benefits than Japanese competitors.Even when autoworkers were laid off, companies couldn't get them off their books. Union-mandated "jobs banks" forced automakers to keep paying workers whose plants had been shut down. They got paid to sit in rooms and do crossword puzzles.Years of losses caused the three U.S. automakers to rack up $200 billion in debt, about half the liabilities that are now strangling Greece. Medical costs for GM workers and retirees added $1,500 to the cost of each car.An increasingly bad situation turned worse during the 2001 recession, which was followed by rising gas prices that lasted for most of the decade. Then came the 2008 financial meltdown. As GM and Chrysler careened toward bankruptcy, Bush stepped in, loaning $17.4 billion to GM and Chrysler just before he left office. But auto sales remained in a free fall, plummeting to a 30-year low of 10.4 million by the end of 2009.At the Orion plant, the recession had slowed sales of the midsized Pontiac G6 and Chevrolet Malibu cars that were made there. In February 2009, the company eliminated a shift and laid off 400 workers. The outlook darkened even more when GM announced it would dump the Pontiac brand. Since the G6 made up half of Orion's production, workers feared the plant was doomed.It didn't take long for issues inside the plant to ripple outside to surrounding industrial parks. Dozens of auto-parts companies laid off workers.About that time, Orion Township's chief executive, Matt Gibb, got a call from Ed Montgomery, Obama's auto-recovery czar, telling him the plant was on a secret list of GM factories to be closed. The factory was the township's largest employer and taxpayer. About a third of its 35,000 residents work for GM, Chrysler or parts suppliers.As Gibb watched the local economy unravel, he was haunted by a documentary he had seen about Janesville, Wis., where another GM plant had closed, leaving behind empty industrial parks and ball fields overgrown with weeds."I don't want to be Janesville," he told friends.Another chanceGM, meanwhile, was drowning, even with emergency loans from the government. On June 1, 2009, it became the largest American industrial company ever to file for Chapter 11 bankruptcy protection. It had just $2 billion in cash and $172.8 billion in liabilities.The bankruptcy wiped out GM's debts, allowed it to shed 21,000 jobs, dump 2,600 dealers and close factories, including Orion."It was like somebody just took the heart out of you," recalled Mike Dunn, the chief United Auto Workers union bargainer at Orion. "You didn't really know if you would have a future."As lawyers for GM and its creditors fought in court over scraps of the company, Orion's second chance emerged.In exchange for its $50 billion bailout, the government got a 60 percent stake in the company and GM agreed to build a tiny car known as the Sonic at one of the U.S. plants it was closing. For folks in Orion like Dunn and Pat Sweeney, the local union president, the mission was clear: Get the Sonic.First, they met with Michigan Gov. Jennifer Granholm and other state officials, who promised GM a $779 million, 20-year tax credit.Gibb spent all spring organizing petition drives and thinking of ways to cut the plant's costs. So when an army of GM lawyers and tax experts showed up at his office, he was ready with a generous package of tax incentives. The township also promised a new $4.5 million water-storage tower and pledged to buy water at off-peak hours so GM could get lower rates.The tax abatement cost the township and its schools about $780,000 per year, but Gibb said it was worth it to save the plant's roughly 3,600 jobs. At the end of June, GM made up its mind: The Orion factory would get the small car. But there was a catch. The plant had to shut down for more than a year to be revamped -- a closure that would further threaten businesses in a fragile economy.Dunn watched as workers removed the plant's equipment, knowing GM could pull out of the deal at any time."You could see from one end to the other," he said. "There was nothing in there but cement and pillars."Negotiating a futureThere was another obstacle. GM and the UAW had to figure out how to cut labor costs at the plant.For decades, the UAW and automakers fought openly as the companies tried to reduce costs and the union demanded pay increases. The UAW would strike, or threaten to, and the companies would cave in. By 2007, GM was paying $1,400 more per vehicle for labor than nonunion Toyota.That same year, both sides agreed to a historic compromise on labor costs. They established a two-tier wage system that would pay new employees around $14 an hour, or half the hourly wage of older workers. Worker pay and pensions were frozen. Union trusts funded by the company and workers would take over retiree healthcare costs. Union President Bob King said each worker gave up at least $7,000 during the four-year contract.But GM still couldn't make money building the Sonic at Orion without a more lower-wage workers. UAW and GM went beyond the national agreement and agreed that more lower-wage workers could be hired at Orion than any other plant in the country -- 40 percent, as opposed to a 25 percent cap like other plants.Can it last?Even when their company was in bankruptcy, GM engineers and designers across the world never stopped working on the Sonic, a new mini car that would take on the Honda Fit and Toyota Yaris. It came with more than just good gas mileage and a lower price: They had aggressive styling, better handling and amenities like leather seats and navigation systems.At GM's expansive technical center, 30 miles south of Orion, engineers worked to make the Sonic accelerate faster and ride quieter than the Aveo, its cheap South Korea-built predecessor. The Sonic emerged with hatchback and four-door versions, and got up to 40 mpg.. The first rolled out of the Orion factory in August 2011.About $1,300 less than the Fit, the tiny Chevy became the best-selling subcompact in the country. Last year, GM sold more than 81,000 Sonics. Hyundai's Accent finished second at 61,000.Industry experts say the reforms Detroit undertook make it less prone to financial disaster. Car companies have closed plants, laid off workers and sold or closed entire brands. GM now has 12 U.S. assembly plants and 101,000 employees in North America. A decade ago, it had 22 plants and 202,000 employees."You literally can't do as many bad things because of the smaller workforce and the smaller portfolio of plants," said David Cole, chairman emeritus of the Center for Automotive Research in Ann Arbor, Mich. "The vulnerability to stupid things is not as great as it used to be."GM, Ford and Chrysler are all building vehicles like the Sonic that can be sold globally, saving billions that used to be spent developing cars for individual markets. Because they are no longer overproducing cars and trucks, they can command higher prices.And they're no longer blindly chasing market share as they did in the early 2000s. GM currently is making money with about 18 percent of the market. U.S. auto sales rose 13 percent last year to 14.5 million, the best in five years."Market share is nice, but profits are essential," Cole said. The government also is getting out of GM's business, which should help sales. Late last year, GM bought back 200 million of the government's shares. That leaves taxpayers holding 300 million shares, which the Treasury plans to sell by early 2014.Detroit could still stumble. GM's inventory is high and its U.S. sales aren't keeping pace with growth in the overall market.