The animal spirits are back. That’s the big story in the new Fortune 500, our annual survey of the nation’s largest companies, ranked by revenues. After a few years of caution following the financial crisis, in 2012 corporate America was once again seized by the “urge to action” famously described by economist John Maynard Keynes. The shift to aggressive behavior is exemplified by two major trends in the 500. The first is an increase in spinoffs, as companies shed nonfundamental business units to concentrate on their core strengths. The second is a resurgence in mergers and acquisitions. For several years players have been hoarding cash and shunning expansion. In 2012 they put that cash — and their rapidly appreciating shares — to work in the best year for M&A in over a decade.
A third trend is closely related to the upswing in M&A: Once again, the 500’s earnings stood near record highs. That performance supplied still more cash and the crucial boost in psychology needed to unleash it. Managers gained confidence that they can maintain strong profitability even in a slowly healing economy.
The spinoff surge created three new Fortune 500 companies on this year’s list. The largest deal came out of Big Oil. The integrated petroleum producers continue to unwind their previous strategy of covering the gamut from drilling to retailing. For several years they’ve been shedding refineries to focus on higher-margin exploration and production. In 2012 the shift accelerated. ConocoPhillips spun off its refining arm as Phillips 66. The new company, Phillips 66 ($169.6 billion in revenues), replaced its former parent at No. 4 on the list, while ConocoPhillips fell to No. 45.
Another spinoff entering the list is Kraft Foods Group (No. 151), the offspring of the former Kraft Foods, which renamed itself Mondelez (No. 88). The new Kraft Foods specializes in groceries and beverages (Philadelphia cream cheese, Maxwell House coffee), while Mondelez markets snacks (Oreo cookies, Cadbury candy bars). The third spinoff to join the 500 is one of America’s largest military shipmakers, Huntington Ingalls Industries (No. 380), a manufacturer of destroyers, aircraft carriers, and Coast Guard cutters. Northrop Grumman (No. 120) shed Huntington to focus on its core aerospace franchise.
MORE: Fortune 500 successful spinoffs
M&A also proved a powerful force in recasting this year’s Fortune 500. Thirteen companies exited the list, accounting for $201 billion in sales. That’s almost triple last year’s revenue total for departed companies, and the highest number since 2000. In 10 of those deals, the buyer was another 500 member that in most cases substantially raised its ranking. Once again energy was a prime mover. Energy Transfer Equity, a pipeline company, purchased Sunoco’s 7,900-mile network of pipelines and 4,900 gas stations, doubling revenues to $17.2 billion and rising from No. 312 to No. 161. In fact, Sunoco, which ranked 61st in 2011, disappeared from the list. The petroleum giant also sold its refinery operations to the Carlyle private equity group, and as a result of the two sales, ceased to exist.
The health care industry continued its consolidation wave. Companies are expanding in areas where the Affordable Care Act is expected to boost business. A notable example is pharmacy benefit management. Express Scripts made a gigantic jump from No. 60 on last year’s list to No. 24 this year by purchasing archrival Medco and now reigns as the nation’s largest manager of prescription drugs. By contrast the tech sector was relatively quiet: The biggest deal was Google’s purchase of Motorola Mobility, making Google (No. 55) not just the supplier of operating systems for Android phones but a manufacturer as well.
Fat profits helped propel those deals. All told, the Fortune 500 earned $820 billion in 2012. That represents a minuscule decline of just $4 billion, or 0.5%, from the all-time record, set in 2011. But some sectors fared far better than others. Autos and auto parts, oil exploration and production, and software earned much less than in 2011, while petroleum refining thrived. In motor vehicles, Ford (No. 10) and General Motors (No. 7) suffered steep declines in earnings, with Ford and GM going from a total of $29 billion to just $11.8 billion. That’s partly because Ford’s 2011 profits were inflated by a huge write-up in the value of its past tax losses. Still, the pair failed to exploit the strong, double-digit growth in the U.S. market, with Ford gaining just 5% in unit sales and GM garnering 3.7%.
MORE: Fortune 500 full list
The shale gas boom continued to flood the market with natural gas and put downward pressure on prices. Three big natural-gas suppliers — Devon (No. 284), Chesapeake (No. 223), and Apache (No. 167) — all saw their profits drop sharply as the price of natural gas plunged 31% in 2012. That collapse forced all three to take large write-downs.
In technology Hewlett-Packard (No. 15) swung from a profit of $7.1 billion in 2011 to a loss of $12.7 billion last year. That’s the deepest deficit on the list and the 26th worst in Fortune 500 history. Two disastrous acquisitions caused most of the damage: HP wrote down $8.8 billion on the value of Autonomy after buying the software maker just 13 months earlier for $11.1 billion, and took another $8 billion charge on its 2008 purchase of Electronic Data Systems.
The comeback sector of the year was financial services. All told, the financial sector boasts the highest total profits of any industry group in the 500 for 2012: $200 billion, or $53 billion more than technology, which came in second. America’s biggest banks — J.P. Morgan Chase (No. 18), Bank of America (No. 21), Wells Fargo (No. 25), and Citigroup (No. 26) — registered strong profit gains, with a surge in mortgage originations aiding J.P. Morgan and Wells, and all the players benefiting from the fast-improving housing market.
The most extraordinary numbers on the entire list, however, come from two casualties of the financial crisis: Fannie Mae (No. 12) and Freddie Mac (No. 31). Those home-loan behemoths lost a combined $258 billion from 2007 to 2011. But last year they earned a total of $28.2 billion, with Fannie’s $17.2 billion in profits ranking sixth among all companies. Fannie and Freddie were helped by a jump in mortgage originations, as well as improved lending standards that enabled them to replace bad loans purchased from 2005 to 2008 with far better-quality mortgages.
MORE: Fortune 500 biggest stock gainers
For the future the overriding question for the 500 is whether the era of abundant profits will continue. Right now earnings amount to 6.8% of sales, far above the historical average of around 5.5%. “The easy profit gains are behind us,” says Mark Zandi, chief economist at Moody’s Analytics. “Margins are as wide as you’ll ever see them, because earnings have grown a lot faster than sales. That can’t continue.” Indeed, U.S. companies have been growing modestly for a couple of years without rehiring the workers they laid off in the panic of 2008 and 2009. As the economy continues to recover, they’ll be forced to both swell their payrolls and pay higher salaries. Most likely that will hold profit growth to the low single digits in the next year or two, in line with sales, as gravitational forces pull earnings back to the mean.
But the fast action that had been missing — that shifts the tectonic plates of U.S. industry and makes the 500 fun to watch — is back. Look for future 500s to pack a gallery of surprises, just like this one.
This story is from the May 20, 2013 issue of Fortune.