Stocks closed broadly higher on Friday, erasing most of the market’s losses for the week and driving the S&P 500 index to its second straight weekly gain.

The rally powered the Nasdaq to an all-time high for the second time this week. The S&P 500 finished just shy of the record high close it reached on Tuesday. Technology and consumer-focused companies did the most to pull the market higher as traders welcomed a strong report on hiring.

On Friday:

The S&P 500 index gained 28.12 points, or 1%, to 2,945.64.

The Dow Jones Industrial Average rose 197.16 points, or 0.7%, to 26,504.95.

The Nasdaq composite climbed 127.22 points, or 1.6%, to 8,164.

The Russell 2000 index of smaller company stocks added 31.37 points, or 2%, to 1,614.02.

For the week:

The S&P 500 rose 5.76 points, or 0.2%.

The Dow fell 38.38 points, or 0.1%.

The Nasdaq gained 17.60 points, or 0.2%.

The Russell 2000 added 22.21 points, or 1.4%.

For the year:

The S&P 500 is up 438.79 points, or 17.5%.

The Dow is up 3,177.49 points, or 13.6%.

The Nasdaq is up 1,528.72 points, or 23%.

The Russell 2000 is up 265.46 points, or 19.7%.