U.S. stocks closed with sharp gains on Tuesday as more companies joined big banks in reporting earnings that beat forecasts, offering respite to investors worried about higher inflation and a tightening Fed denting the corporate bottomline.

The S&P 500 gained 2.8%, the highest close since June 9. The tech-heavy Nasdaq Composite added 3.1%, marking the biggest one-day percentage gain since June 24.

Shares of Halliburton rose 2.1% after the oilfield services provider posted a 41% increase in quarterly adjusted profit.[L4N2Z02BA] Toymaker Hasbro Inc gained 0.7% after reporting quarterly profit ahead of expectations.

Truist Financial Corp also beat market estimates for quarterly profit, sending the bank's shares up 2.6%.

"Earnings have come in better than lowered expectations," said Paul Kim, CEO of Simplify Asset Management in New York.

"So we're not seeing the bite of tighter monetary policy and inflation impacting revenue as much as feared."

Johnson & Johnson shares lost 1.5%, reversing earlier gains. The healthcare giant reported profit and sales that exceeded expectations but cut its earnings outlook for the year due to a soaring U.S. currency.

A strong dollar also weighed on shares of IT hardware and services company IBM Corp, which beat quarterly revenue expectations on Monday but warned the hit from forex for the year could be about $3.5 billion.

The U.S. dollar marked its third straight day of declines as markets reduced the odds of a full percentage-point Federal Reserve rate hike this month. [USD/]

Spiraling inflation initially led markets to price in a 100-basis-point hike in interest rates at the upcoming Fed meeting later this month, until some policymakers signaled a 75-basis-point increase.

The Dow Jones Industrial Average rose 754.44 points, or 2.43%, to 31,827.05, the S&P 500 gained 105.84 points, or 2.76%, to 3,936.69 and the Nasdaq Composite added 353.10 points, or 3.11%, to 11,713.15.

"The macro picture hasn't changed," said Kim. "We still have falling earnings, high inflation pressures and a tightening Fed. So longer term, I don't think this type of rally has staying power."

In this earnings season, analysts expect aggregate year-on-year S&P 500 profit to grow 5.8%, down from the 6.8% estimate at the start of the quarter, according to Refinitiv data.

Volume on U.S. exchanges was 10.95 billion shares, compared with the 11.76 billion average for the full session over the last 20 trading days.

Advancing issues outnumbered declining ones on the NYSE by a 4.88-to-1 ratio and on the Nasdaq, a 3.40-to-1 ratio favored advancers.

The S&P 500 posted one new 52-week high and 30 new lows; the Nasdaq Composite recorded 31 new highs and 56 new lows.