Stocks closed out the worst month in more than a year on an up note on Wednesday, with sharp gains in the last several days still not enough to repair the damage from a U.S. credit downgrade and fears of a slide back into recession.

Sentiment turned dramatically in recent days on expectations the Federal Reserve will again intervene to support the economy. With Wednesday's gains, the Dow was back in positive territory for 2011.

Banks led a late-day surge on Wednesday, helping to extend a four-day rally, followed by industrial shares. JPMorgan Chase & Co rose 1.3 percent to $37.56 while Caterpillar Inc was up 1.3 percent at $91.00.

Minutes from the most recent Fed policymakers' meeting released on Tuesday that indicated several Fed members favored more monetary easing bolstered the appetite for equities.

The market has been somewhat schizophrenic lately, but the idea of more stimulus lets you put a rosy spin on everything, said Steve Sosnick, equity-risk manager at Timber Hill/Interactive Brokers Group in Greenwich, Connecticut.

Our rally has quieted down since the data wasn't great this morning, and we still don't know if that kind of weakness will be enough to trigger 'extraordinary action' from the Fed, he said.

Federal Reserve Chairman Ben Bernanke, at an annual Fed conference in Wyoming last week, said the U.S. central bank's scheduled meeting in September would run for two days instead of the planned one to mull options for additional monetary stimulus.

Data on hiring by private employers in August and factory activity in the U.S. Midwest released on Wednesday showed some signs of weakening growth.

The Dow Jones industrial average <.DJI> finished up 53.58 points, or 0.46 percent, at 11,613.53. The Standard & Poor's 500 Index <.SPX> was up 5.97 points, or 0.49 percent, at 1,218.89. The Nasdaq Composite Index <.IXIC> was up 3.35 points, or 0.13 percent, at 2,579.46.

The S&P 500 rose in seven of the past eight sessions for total gains of 8.5 percent, led by sectors tied to economic growth.

For August, though, the S&P fell 5.7 percent, its worst month since May 2010. The Dow fell 4.4 percent in August while the Nasdaq slumped 6.4 percent. It was the fourth straight down month for all.

Equities on Wednesday were volatile late in the session, turning briefly negative before snapping back into positive territory. Still, the volatility did not compare to early in the month, when Wall Street was marked by massive swings of more than 3 percent.

The market has no conviction one way or the other, and the low volume exaggerates all the moves we get, said Carl Kaufman, who helps manage just under $2 billion at the Osterweis Strategic Income fund in San Francisco.

We get some good numbers, but there are questions about the future, a lot of people are still seeking safety. The market is a zephyr in the whirlwind of headlines.

An index of factory activity in the U.S. Midwest slipped to its lowest level since November 2009, though the figures still pointed to manufacturing growth. A separate report showed private sector job growth slowed in August for a second straight month.

Tech shares weighed on the Nasdaq, with Apple Inc off 1.3 percent to $384.83 and chipmaker Nvidia Corp down 2.7 percent to $13.31.

Industrial stocks were among the top gainers, with the S&P industrials index <.GSPI> up 0.7 percent. Honeywell International gained 1.1 percent to $47.81 while Joy Global Inc rose 1.3 percent to $83.45. The company agreed to sell the drilling products business of recently acquired LeTourneau Technologies to Cameron International Corp for $375 million.

Telecom stocks were the day's losers after the Obama administration filed to block AT&T Inc's $39 billion proposed acquisition of T-Mobile USA from Deutsche Telekom because of anti-competitive concerns.

AT&T shares slumped 3.8 percent to $28.48, the biggest decliner on the Dow. The S&P Telecommunications index <.GSPL> dropped 1.6 percent, by far the biggest loser among S&P sectors.

New orders for U.S. factory goods rose more than expected in July as demand for transportation equipment surged, pointing to some resilience in manufacturing at the start of the third quarter.

Almost two stocks rose for every one that fell on the New York Stock Exchange, while on the Nasdaq slightly more stocks fell than rose.

About 8.2 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 Leslie Adler)