U.S. stocks rose on Friday and the S&P and Nasdaq indexes registered their biggest weekly percentage gains since the U.S. elections in early November, boosted by optimism over earnings, stimulus talks and progress in vaccine rollouts.

The S&P 500 rose for a fifth straight session in its longest streak of gains since August. The benchmark index and the Nasdaq posted record closing highs for a second day.

A smaller-than-expected rebound in the labor market last month highlighted the need for more government aid to shore up the economy. The Labor Department's data showed job losses in manufacturing and construction, the two sectors that have been propping up the economy. Job losses in December were also deeper than initially thought. 

U.S. President Joe Biden's drive to enact a $1.9 trillion coronavirus aid bill gained momentum on Friday with the U.S. House of Representatives set to vote on a budget plan that would allow the passage of the legislation in coming weeks without Republican support. 

"The upcoming package of stimulus is going to be big," said Alan Lancz, president of Alan B. Lancz & Associates Inc, an investment advisory firm based in Toledo.

"You have a situation where there's a lot of cash on sidelines and bonds have really underperformed, so that's helped some sectors that have really done poorly."

Unofficially, the Dow Jones Industrial Average rose 87.45 points, or 0.28%, to 31,143.31, the S&P 500 gained 15.06 points, or 0.39%, to 3,886.8 and the Nasdaq Composite added 78.55 points, or 0.57%, to 13,856.30.

The S&P 500 technology sector slipped after hitting a record high earlier in the session.

Johnson & Johnson rose after the drugmaker said it had asked U.S. health regulators to authorize its single-dose COVID-19 vaccine for emergency use. 

Shares of GameStop Corp, caught in the recent social media-hyped trading frenzy, was higher on Friday, after online broker Robinhood lifted all the buying curbs imposed at the height of the battle between amateur investors and Wall Street hedge funds. 

So far, stronger-than-expected corporate results in the fourth quarter have driven up analysts' expectations, and S&P 500 companies are on track to post earnings growth for the period instead of a decline as initially expected.

(Additional reporting by Devik Jain and Medha Singh in Bengaluru; Editing by Maju Samuel and Richard Chang) ((caroline.valetkevitch@thomsonreuters.com; +1 646 223 6393; Reuters Messaging: caroline.valetkevitch.thomsonreuters.com@reuters.net))