Stocks closed higher Thursday after a furious, late-afternoon rally erased steep losses.

The market had been down most of the day as the selling that has gripped Wall Street for most of December resumed. At its lowest, the Dow Jones Industrial Average was down 611 points. Even with the rally, the major stock indexes remain sharply lower for December and down for the full year with only two trading sessions remaining.

On Thursday:

The S&P 500 index rose 21.13 points, or 0.9 percent, to 2,488.83.

The Dow gained 260.37 points, or 1.1 percent, to 23,138.82.

The tech-heavy Nasdaq added 25.14 points, or 0.4 percent, to 6,579.49.

The Russell 2000 index of smaller-company stocks picked up 2.01 points, or 0.2 percent, 1,331.82.

For the week:

The S&P 500 is up 72.21 points, or 3 percent.

The Dow is up 693.45 points, or 3.1 percent.

The Nasdaq is up 246.50 points, or 3.9 percent.

The Russell 2000 is up 39.73 points, or 3.1 percent.

For the year:

The S&P 500 is down 184.78 points, or 6.9 percent.

The Dow is down 1,580.40 points, or 6.4 percent.

The Nasdaq is down 323.90 points, or 4.7 percent.

The Russell 2000 is down 203.69 points, or 13.3 percent.