Investors rode out another turbulent day on Wall Street that kept stock indexes flipping between gains and losses until a late-day bounce gave the market a modest gain.
The S&P 500 and the Dow gained ground in a late rally on Thursday as upbeat retail sales data offset recessionary fears amid the simmering US-China trade tensions.
Wall Street zig-zagged from red to black and back much of the day as investors juggled mixed messages of a strong consumer and dropping US Treasury yields.
The Nasdaq closed lower, weighed by a plunge in the shares of Cisco Systems Inc.
"You've an environment where we're digesting the move down in interest rates and the yield curve yesterday," said Darrell Cronk, chief investment officer for Wells Fargo Wealth and Investment Management in New York. "Volume is lighter today. You're not getting outsized movements one way or the other."
Walmart Inc beat second-quarter analyst estimates and raised its full-year earnings outlook, sending shares of the world's largest retailer up 6.1 percent and soothing concerns about waning consumer demand.
Those concerns were further eased when retail sales data surpassed analyst expectations. Consumers, who account for about 70 percent of the US economy, stepped up their spending across the board in July, according to the Commerce Department.
"One thing the market took solace in today is better US economic data," Cronk added. "That helped to calm some of the fears from yesterday."
Other economic data was less sanguine. Manufacturing output shrank more than expected in July, according to the US Federal Reserve, and new claims for unemployment benefits came in above economist forecasts.
Belligerent rhetoric kept US-China trade tensions at a low boil, as China vowed it would counter the last round of tariffs on Chinese imports and called on the United States to meet it halfway, while US President Donald Trump said in an interview any deal must be made "on our terms."
The prolonged escalation of the trade war between the world's two largest economies and the economic fallout have vexed global markets for months and have begun to drag on some companies' top lines.
Impending US tariffs weighed on Cisco Systems, which plunged 8.6 percent after reporting a 25 percent drop in China sales and set sales and revenue forecasts well below analyst estimates.
Trade tensions also sent the US 30-year Treasury yield to a record low and the benchmark 10-year yield to a three-year trough.
Will Denselow explains the turnaround.
The Dow Jones Industrial Average rose 99.97 points, or 0.39 percent, to 25,579.39, the S&P 500 gained 7 points, or 0.25 percent, to 2,847.6, and the Nasdaq Composite dropped 7.32 points, or 0.09 percent, to 7,766.62.
Of the 11 major sectors of the S&P 500, six closed the day in positive territory, with consumer staples enjoying the largest percentage gain.
Shares of JC Penney Co Inc surged 2.2 percentage points after the struggling department store operator posted a smaller quarterly loss than analysts estimated.
General Electric Co shares dropped 11.3 percent on the heels of a report from whistleblower Harry Markopolos accusing the conglomerate of hiding $38.1 billion in potential losses and claiming its cash situation was far worse than disclosed.
Advancing issues outnumbered declining ones on the NYSE by a 1.08-to-1 ratio; on Nasdaq, a 1.37-to-1 ratio favoured decliners.
The S&P 500 posted 14 new 52-week highs and 59 new lows; the Nasdaq Composite recorded 23 new highs and 282 new lows.
Volume on US exchanges was 7.72 billion shares, compared with the 7.53 billion average over the last 20 trading days.