US stocks have ended higher as electric car maker Tesla rose on its stronger than expected quarterly results, which helped offset a slide in telecom and energy shares.
Tesla shares surged while AT&T Inc tumbled, sending telecom shares down after the wireless carrier cut its cash flow forecast saying some subscribers were delaying bill payments.
Energy stocks slipped on weak crude prices.
Tesla's profit benefited from a price hike of its cars, offsetting production challenges.
Strong reports from the car maker and streaming giant Netflix Inc have boosted megacap growth stocks that have been under pressure from rising interest rates.
"The earnings picture has been maybe a little better than investors feared," said J Bryant Evans, investment adviser and portfolio manager at Cozad Asset Management.
"We investors are thinking that... especially technology (sector) has come down too far, and maybe there's some valuation opportunities there."
The S&P 500 gained 39.39 points, or 0.99 per cent, to end at 3,999.29 points, while the Nasdaq Composite gained 162.94 points, or 1.35 per cent, to 12,060.59 and the Dow Jones Industrial Average rose 165.79 points, or 0.52 per cent, to 32,036.84.
Falling oil prices hit the S&P 500 energy sector, which tumbled to lead declines across the 11 major sectors.
Market participants continue to await anxiously for the US Federal Reserve meeting next week where policymakers are expected to raise interest rates by 75 basis points to curb runaway inflation.
Joining its global peers, the European Central Bank delivered a 50 basis points rate hike to tame inflation in its first rate increase since 2011.
The Fed rate decision next week will be followed by the crucial second-quarter US gross domestic product data, which is likely to be negative again.
By one common rule of thumb, two quarters of negative GDP growth would mean the United States is in a recession.
The number of people in the US enrolling for unemployment benefits rose to the highest in eight months, the latest data to further fan fears of a recession.
"Consumers are just beginning to react to less money in their pockets, either from reduced overall job market or from rising interest rates and inflation," Evans added.
"Part of the strong earnings reflects the past strength of consumers, whereas a lot of this broader decline that we've seen... over the past few months has priced in a slowing in broader economy that eventually would affect consumers."