Stocks were well off their highs but still posting solid gains after unexpected strength in retail sales and a multibillion-dollar takeover bid in the brewing sector.
The market lost some of its gains after oil prices , which initially were off more than $3 a barrel, rallied in the afternoon and ended up near $137.
Advances were broad based, with shares of big manufacturers such as Caterpillar - up nearly 2 percent -- and plane maker Boeing - up nearly 4 percent -- among the biggest gainers, followed by shares of financial services companies.
Retail sales rose 1 percent -- twice the gain expected -- in May, boosted by the government-rebate checks. Excluding gasoline, sales still rose by a robust 0.8 percent. Excluding autos, sales rose 1.2 percent, the biggest rise in six months.
Among retailers, Wal-Mart Stores shares shot up nearly 2 percent, while Costco shares gained 1.4 percent.
Shares of brewer Anheuser-Busch jumped more than 6 percent following news that the maker of Bud Light and Michelob beers had received an unsolicited $46.3 billion takeover bid from Belgian rival InBev
ADRs of InBev jumped amid enthusiasm for the Anheuser-Busch deal. If it goes through, the deal would be the biggest takeover in the beer industry ever. However, analysts say InBev, which makes Stella Artois and Beck's beers, will probably raise the price from the initial $65 a share it was offering for Anheuser-Busch.
This is the second big M&A announcement this week: Staples on Tuesday confirmed its plans to buy Dutch office supplier Corporate Expressfor $2.6 billion.
The market started Thursday's session at its most oversold condition since early March, according to the 14-day relative strength index of the S&P 500 index.
Lehman Brothers shares recovered from an earlier plunge but remained wobbly following news that CFO Erin Callan and operating chief Joseph Gregory were ousted from their high-level positions at the struggling brokerage firm.
Among financials, shares of JPMorgan Chase shot up nearly 4 percent, while Citigroup jumped 3.3 percen.
But even with the advance investors kept one eye on developments at Lehman Brothers after the investment bank replaced its chief financial officer and its chief operating officer.
The recovery for banks is still a long way off, despite their efforts to raise capital, Meredith Whitney, executive direct of equity research at Oppenheimer & Co, said. Whitney said all bank dividends are at risk.
Like an instant prophecy, KeyCorp cut its dividend in half and said it plans to raise $1.5 billion in fresh capital.
In a sign the tide may be turning, however, Morgan Stanley upgraded its rating on financial stocks and downgraded its rating on the energy sector.
Shareholders of American International Group are asking for changes to the management and board of the world's largest insurer, which has been struggling with the fallout of the subprime mortgage mess.
Standouts also included technology shares, with wireless chip maker Qualcomm up nearly 4 percent after raising its quarterly profit outlook.
Still to Come:
THURSDAY: Natural-gas inventories
FRIDAY: CPI, consumer sentiment