Wall Street bulls took the upper hand with a 1 percent rally on Tuesday as hopes for a new plan to deal with Greece's debt crisis relieved some investor worry, but grim economic data suggested more hurdles ahead as the S&P 500 closed out its worst month since August.

Stocks rebounded late in the session, nearing levels that were approached at the open, but later fell following lackluster data on U.S. Midwestern factory demand and consumer confidence.

Today is a good day, but the fact that the Dow gave up its early gains and is going to close lower for the month, isn't positive, said Donald Selkin, chief market strategist at National Securities in New York. There's a conflict between the economic reports coming in lower than expected and the hope for resolution out of Greece.

A Reuters poll showed investors are the most bearish they have been since the third quarter of last year on concerns about a slowing economy and the situation in Greece. Investors have cut their equity exposure for the fourth straight month.

Selkin noted that the CBOE Volatility Index <.VIX>, or VIX, was at low levels, down 15.3 percent since May 23.

That means the upside potential is limited. Without a doubt, stocks are going to be stuck in a range for a while.

European officials were mulling options for a second bailout package for Greece, with private-sector participation still under discussion. Germany, which was resisting extra funding, may drop its push for an early rescheduling of Greek bonds, the Wall Street Journal reported.

Rising expectations for a package pushed the dollar down against the euro, helping lift commodity prices and materials stocks. Crude futures rose 2 percent while Chevron Corp gained 1.6 percent to $104.91 and Alcoa Inc added 2 percent to $16.81. The S&P energy index <.GSPE> added 1.04 percent.

The Dow Jones industrial average <.DJI> shot up 128.21 points, or 1.03 percent, to 12,569.79. The Standard & Poor's 500 Index <.SPX> gained 14.10 points, or 1.06 percent, to 1,345.20. The Nasdaq Composite Index <.IXIC> rose 38.44 points, or 1.37 percent, to 2,835.30.

For May, the Dow lost 1.9 percent and the Nasdaq fell 1.3 percent. The S&P fell 1.4 percent, its worst month since August, when the U.S. Federal Reserve announced the second round of its quantitative easing program.

U.S. single-family home prices dropped in March, dipping below their 2009 low, according to the S&P/Case-Shiller composite index of 20 metropolitan areas. A separate report showed an unexpected drop in May consumer confidence, while the Institute for Supply Management-Chicago said business activity in the U.S. Midwest grew much less than expected in May.

Robert Phipps, director at Per Stirling Capital Management in Austin Texas, said the data was disappointing, and it helps affirm the fact that the economy is, in fact, slowing.

Tech shares also lifted the market, with the S&P information technology index <.GSPT> up 1.6 percent. Cisco Systems Inc was one of the Dow's top gainers, up 2.1 percent at $16.80, while Apple Inc climbed 3.1 percent to $347.83 on the news that Steve Jobs, its chief executive who has spent months on medical leave, would open an annual developer's conference.

Goldman Sachs Group Inc climbed 1.5 percent to $140.73 after the company was upgraded to overweight from neutral by JPMorgan, which said the market had overreacted to a U.S. Senate panel's report on the bank.

U.S.-listed shares of Nokia Corp slumped 14.4 percent to $7.02 after it abandoned hope of meeting key targets just weeks after setting them. The stock dropped on its heaviest volume since February.

About 74 percent of the stocks traded on the New York Stock Exchange closed in positive territory, while 67 percent of the Nasdaq did.

Volume was light, with about 8.20 billion shares traded on the New York Stock Exchange, the American Stock Exchange and Nasdaq, below last year's daily average of 8.47 billion.

(Editing by Jan Paschal)