NEW YORK (Reuters) - 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 U.S.-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 U.S. 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% 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% of the U.S. 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 U.S. 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 U.S. Federal Reserve, and new claims for unemployment benefits came in above economist forecasts.

Belligerent rhetoric kept U.S.-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 U.S. President Donald Trump said in an interview any deal must be made “on our terms.”

FILE PHOTO: Traders work on the floor at the New York Stock Exchange (NYSE) in New York, U.S., August 13, 2019. REUTERS/Eduardo Munoz

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 U.S. tariffs weighed on Cisco Systems, which plunged 8.6% after reporting a 25% drop in China sales and set sales and revenue forecasts well below analyst estimates.

Trade tensions also sent the U.S. 30-year Treasury yield to a record low and the benchmark 10-year yield to a three-year trough.

The Dow Jones Industrial Average rose 99.97 points, or 0.39%, to 25,579.39, the S&P 500 gained 7 points, or 0.25%, to 2,847.6, and the Nasdaq Composite dropped 7.32 points, or 0.09%, 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% after the struggling department store operator posted a smaller quarterly loss than analysts estimated.

General Electric Co shares dropped 11.3% 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 favored 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 U.S. exchanges was 7.72 billion shares, compared with the 7.53 billion average over the last 20 trading days.