With massive fiscal stimulus helped the U.S. economy grow at a 6.4% annualized rate in the first quarter, investors have been banking on an infrastructure agreement that could steer the next leg of the recovery for the world's largest economy and fuel more stock gains.

Construction and mining equipment maker Caterpillar and aerospace firm Boeing both jumped more than 2%, helping lift the Dow Jones Industrial Average.

"In the short term, I think there will be some 'buy the rumor and sell the news' in materials and industrials, but as we start to see more details come out about how the money will be spent, I think we will get a continued benefit," said Sal Bruno, chief investment officer at IndexIQ in New York.

Fueling the S&P 500's gains more than any other stock, Tesla Inc rose 3.5% after Chief Executive Officer Elon Musk said he would list SpaceX's space internet venture, Starlink, when its cash flow is reasonably predictable, adding that Tesla shareholders could get preference in investing.

Mega-caps PayPal and Facebook Inc each gained more than 1%, and were also among the biggest boosts to the S&P 500 and the Nasdaq.

Microsoft added 0.5% and ended with a market capitalization above $2 trillion for its first time.

Initial claims for state unemployment benefits fell 7,000 to 411,000 for the week ended June 19, the Labor Department said on Thursday, but were still higher than the 380,000 that economists had forecast.

The Commerce Department said the economy grew at a 6.4% rate last quarter, unrevised from the estimate published in May.

So far this month, the S&P 500 growth index has climbed almost 4%, outperforming the value index's 2% drop.

(Graphic: S&P 500 Forward PE, )

The Dow Jones Industrial Average rose 0.95% to end at 34,196.82 points, while the S&P 500 gained 0.58% to 4,266.49.

The Nasdaq Composite climbed 0.69% to 14,369.71.

Volume on U.S. exchanges was 9.2 billion shares, less than the 11.0 billion average over the last 20 trading days.

The S&P 500 technology, healthcare and communication services sector indexes hit record highs.

So far in 2021, the S&P 500 has gained almost 14%, beating the Nasdaq's 11% rise.

Eli Lilly and Co jumped 7.3% to a record high after the drugmaker said it would apply for the U.S. Food and Drug Administration's accelerated approval for its experimental Alzheimer's drug this year.

In response, Biogen Inc, which received a controversial approval for its Alzheimer's drug aducanumab earlier this month, tumbled 6.1%.

MGM Resorts International rose 2.2% after Deutsche Bank upgraded the casino operator's stock to "buy" from "hold."

Accenture Plc gained 2.1% after the IT consulting firm raised its full-year revenue forecast.

Advancing issues outnumbered declining ones on the NYSE by a 2.29-to-1 ratio; on Nasdaq, a 2.44-to-1 ratio favored advancers.

The S&P 500 posted 36 new 52-week highs and 1 new lows; the Nasdaq Composite recorded 105 new highs and 27 new lows.

(Additional reporting by Devik Jain and Medha Singh in Bengaluru; Editing by Maju Samuel and Aurora Ellis)

By Noel Randewich and Devik Jain