The S&P 500 has rallied to finish higher and secure its biggest quarterly percentage gain in more than two decades as improving economic data bolstered investor beliefs that a stimulus-backed rebound for the US economy was on the horizon.

Coming off a drop of 20 per cent in the first quarter, the biggest quarterly decline since the financial crisis in the fourth quarter of 2008, the S&P rallied more than 19.95 per cent to notch its biggest quarterly gain since 1998, at the height of the tech boom.

The gains have been fuelled by unprecedented levels of fiscal and monetary stimulus and the easing of restrictions.

But the S&P 500 is still down about four per cent on the year, and gains in June stood at just two per cent due to the flare-up in virus cases that has threatened to delay reopenings and derail a tentative economic recovery.

Federal Reserve Chairman Jerome Powell reiterated in comments on Tuesday that the path of the economy is “highly uncertain”.

JJ Kinahan, chief market strategist at TD Ameritrade in Chicago, said if the virus spread can be stopped or slowed it would have a huge impact on the market.

“What everybody sees is if we can get something that puts an end to the spread or the spread becomes less, there is literally so much money out there that the Fed has put out there that when we turn, it is going to be a rocket ship the other way,” he said.

Still, comments from Anthony Fauci, the US government’s top infectious diseases expert, were a reminder that a full economic recovery could be a long road.

Fauci said there was no guarantee the United States will have an effective COVID-19 vaccine and warned the virus spread “could get very bad”.

Gains were capped on the Dow on Tuesday, pressured by a 5.75 per cent drop in Boeing, as the plane maker gave back some of Monday’s 14 per cent surge after Norwegian Air cancelled orders for 97 aircraft and said it would claim compensation.

The Dow Jones Industrial Average rose 217.08 points, or 0.85 per cent, to 25,812.88 on Tuesday, the S&P 500 gained 47.05 points, or 1.54 per cent, to 3,100.29 and the Nasdaq Composite added 184.61 points, or 1.87 per cent, to 10,058.77.

The 17.78 per cent gain in the Dow marked its best quarterly performance since a 21.56 per cent rally in the first quarter of 1987 while the Nasdaq’s 30.63 per cent jump was its best quarter since a 48.18 per cent gain in the fourth quarter of 1999.

While coronavirus cases continue to surge in many states, the US economy is showing signs of pick-up, with data indicating consumer confidence increased much more than expected in June.

Simmering US-China tensions also remained a possible headwind, with Washington beginning to eliminate Hong Kong’s special status under US law in response to China’s national security law for the territory. China said it would retaliate.

All of the 11 major S&P 500 sectors traded higher, with a 2.2 per cent rise in energy stocks leading the pack.

Micron Technology jumped 4.8 per cent as it forecast higher-than-expected current-quarter revenue on strong demand for its chips that power notebooks and data centres.

The company’s results also boosted other chipmakers and lifted the Philadelphia semiconductor index by 2.7 per cent.

Uber advanced 4.9 per cent after reports the ride-hailing services company was in talks to buy food-delivery app Postmates.

Advancing issues outnumbered declining ones on the NYSE by a 2.02-to-1 ratio; on Nasdaq, a 2.09-to-1 ratio favoured advancers.

The S&P 500 posted 13 new 52-week highs and one new low; the Nasdaq Composite recorded 76 new highs and 16 new lows.

Volume on US exchanges was 10.72 billion shares, compared with the 13.55 billion average for the full session over the last 20 trading days.