NEW YORK — Continued worries about Europe’s lingering debt crisis overshadowed a small rebound in oil prices and pushed stocks slightly lower Tuesday.

Oil rose nearly $2 to $99.59 per barrel after major banks raised their forecasts for crude prices. Goldman Sachs, J.P. Morgan and Morgan Stanley analysts predicted a rise in global demand would drive oil prices higher later this year. Goldman analysts say oil prices could reach $135 a barrel by the end of 2012.

Stocks swung between gains and losses throughout the day, with Chevron Corp. and other energy companies posting the largest gains. Energy companies in the S&P 500 rose 1.3 percent, the most of the ten industry groups in the index.

The Dow Jones industrial average fell 25.05 points, or 0.2 percent, to close at 12,356.21. The Standard & Poor’s 500 index fell 1.09 point to 1,316.28. The Nasdaq composite fell 12.74, or 0.5 percent, to 2,746.16.

Stocks had been on a tear for the first four months of the year, lifted by stronger earnings reports, an improving job market and other signs of economic recovery. But all three major indexes have lost more than 3.5 percent this month, even as earnings remain strong. Widespread optimism has been shoved aside by a host of concerns, especially the impact of higher oil prices on consumer spending and the risk that Europe’s debt troubles could get worse.

Markets faced more troubling news about Europe on Tuesday, when Greece’s main opposition party said it opposed the government’s latest attempts to reduce debt. The news further dampened hopes that the country might be able to repair its finances enough to get another loan package from the International Monetary Fund.

Ratings agency Moody’s also warned that a restructuring of Greece’s debt would be considered a default. That would cause borrowing costs for other debt-strapped European countries to soar.

Uri Landesman, president of hedge fund manager Platinum Partners, said a Greek default could start a chain reaction affecting larger countries like Spain — the fourth-largest economy in Europe — wreaking havoc on the global economy.

“If you had a Spanish default, there wouldn’t be a single world bank not affected,” Landesman said.

U.S. banks had $187 billion at stake in Spain as of the end of last September, according to the most recent data from the Bank of International Settlements. The amount includes holdings of government debt, derivative contracts and other commitments.

European stocks managed to recover from Monday’s declines, in part because of a reassuring report from Germany that business optimism was holding steady.

Both Germany’s DAX and England’s FTSE 100 ended the day 0.4 percent higher. France’s CAC-40 added 0.3 percent. The euro also rose slightly against the dollar after falling to a two-month low Monday.

The U.S. Commerce Department reported that more people bought new homes for a second straight month in April, a hopeful sign. Still, sales remain far below a pace that would signal a turnaround for the depressed housing market.

New-home sales rose 7.3 percent last month to a seasonally adjusted annual rate of 323,000, according to Tuesday’s report. A healthy real estate market would produce about 700,000 new-home sales a year.

People have little incentive to buy new homes, in part because they’re comparatively expensive. The median price of a new home rose more than 2 percent from March to $217,900. New-home prices are more than 30 percent higher the median price of re-sales — twice the normal markup.

The latest sales numbers come in the midst of a weak spring home-buying season. Analysts had been forecasting an uptick in sales for the past several months. It hasn’t happened. April’s new-home sales are 23 percent lower than in the same month last year.

Many would-be buyers of new homes are instead favoring older, discounted re-sale homes, said Paul Bell, a Realtor with the Prudential Americana Group in Las Vegas.

“That’s where the deals are,” Bell said.

Energy company El Paso Corp. rose 6 percent, the most of any stock in the S&P 500, after saying it plans to split itself into two publicly-traded businesses by the end of this year.

AutoZone Inc. rose 6 percent after the specialty retailer’s earnings jumped 12 percent on strong sales of its Duralast auto parts.

Stanley Black & Decker Inc. fell 2 percent.

Falling shares outpaced rising ones by a small margin on the New York Stock Exchange. Trading volume was 3.6 billion shares.