But the finish sure was ugly. The Dow Jones industrial average fell 276 points and finished below 12,000 on the final day of the month. It was as rough an ending as it was a beginning: On the first trading day of October, the Dow lost 258.
Bank stocks were hit hard Monday. MF Global, a securities firm headed by former New Jersey Gov. Jon S. Corzine, filed for bankruptcy protection. Rating agencies downgraded the company last week, worried that it holds too much European debt.
For the month, the Dow rose more than 1,000 points. It gained 9.5 percent, its best showing since October 2002. The Standard & Poor's 500 index, the broadest major market average, rose 10.8 percent for the month, the best since December 1991.
On Oct. 3, both the Dow and the S&P closed at their lows of the year. The market had been through a brutal summer and was one bad day away from falling into bear market territory, down 20 percent from its most recent peak. Investors were worried that the United States, with an economy growing at the slowest pace since the end of the Great Recession, was on the brink of falling back into recession.
Someone opening a quarterly account statement at about that time might have tossed it in the garbage and been afraid to look again. But that day was to be the turning point.
With the October books closed, the Dow was at 11,955.01, up about 83 percent from March 2009, its lowest point after the financial meltdown. It would have to rise more than 2,200 points from here to set an all-time high.
The S&P 500 finished the month at 1,253.50, down 32 points on Monday, or 2.5 percent. The Nasdaq composite index fell 53 points for the day, or 1.9 percent, and ended October at 2,684.
Worries about a second recession have receded somewhat. The government announced last week that the economy in July, August and September grew at an annual rate of 2.5 percent, more than twice the speed of earlier this year.
The European debt crisis is still far from fixed. One troubling sign is that borrowing costs for Italy and Spain have increased, a signal that traders remain worried about those countries' ability to pay their debts.
And there are problems closer to home. A congressional "supercommittee" has to find $1.2 trillion in deficit cuts in less than a month, and Republicans and Democrats are fighting about whether to focus on higher taxes or cuts in federal spending.