NEW YORK - The oil rally is on again.
Stocks closed higher Wednesday for the first day this week as rising oil prices offset worries about the global economic recovery. Oil rose nearly $2 to settle at $101.32 per barrel, pushing energy stocks higher.
Cabot Oil & Gas Corp. led the S&P 500, rising 7 percent. Higher prices for copper, silver, and other commodities lifted miners and other material companies. Freeport-McMoRan Copper & Gold Inc. gained 2 percent.
The Dow Jones industrial average rose 38.45 points, or 0.3 percent, to close at 12,394.66. The Standard & Poor's 500 index rose 4.19, or 0.3 percent, to 1,320.47. The Nasdaq composite rose 15.22, or 0.6 percent, to 2,761.38.
Markets have been battered in recent days by new worries over Europe's debt crisis. The last time stocks closed higher had been Thursday, when investors welcomed a blockbuster initial public offering by the social-networking site LinkedIn Corp.
Greece's government and opposition party failed late Tuesday to agree on how to pare the country's debts, adding to the uncertainty about Greece's financial future. Many analysts believe Greece will have to restructure its debt, possibly by extending interest payments or lowering interest rates.
Without that restructuring, Greece might default. That would raise borrowing rates for larger European countries and hamper the world economy.
Japan's government reported that the country's exports had fallen 12.5 percent in April after the March 11 earthquake and tsunami shuttered factories and forced manufacturers to stop production. Japan's auto shipments were particularly hurt, dropping 67 percent.
The drop in Japanese exports hit orders for long-lasting goods in the United States. The Commerce Department said companies had ordered fewer computers, heavy machines, cars, and airplanes from factories in April. The 3.8 percent drop was the biggest in six months.
Stocks had climbed steadily since August until the Japanese catastrophe shook global financial markets in March.
Some analysts say the market may have been rising too far too fast since the beginning of the year, making stocks seem expensive. The Dow is still up 7 percent for the year. The S&P 500 is up 5 percent.
Fertilizer company CF Industries rose 3 percent a day after JPMorgan upgraded the stock, citing the company's good cash flow and positive predictions for the agriculture industry.
Martha Stewart Living Omnimedia jumped 24 percent. The company said it had hired the Blackstone Group as an adviser, triggering speculation that the company will be put up for sale.
Retail stocks struggled. Polo Ralph Lauren Corp. sank 11 percent after reporting that higher costs pushed profit down 36 percent. Costco Wholesale Corp. slipped 1 percent after reporting earnings that missed analysts' estimates.
American International Group Inc. fell 4 percent to $28.28 as the U.S. Treasury Department sold some of its stake in the company. Treasury said it would sell 300 million AIG shares for $29 each, making a small profit. The price was set late Tuesday at the low end of the government's projected range.