Stocks rose on Thursday, making back some of the steep losses in the previous session, as retail giant Walmart's earnings and strong retail sales figures led investors to believe the U.S. consumer could help the country avoid a recession.

The Dow Jones Industrial Average ended the volatile session 99.97 points, or 0.39%, higher to 25,579.39 after suffering its worst day of the year Wednesday. The S&P 500 was up 0.25%, or 7 points, to 2,847.6, while the Nasdaq Composite was slightly lower at 7,766.62.

Retail sales rose solidly in July and beat expectations, the Commerce Department said Thursday. Consumers spent more at stores and restaurants last month, a sign that fears of a global slowdown that have roiled financial markets haven't soured consumer optimism.

Walmart reported better-than-expected earnings and raised its outlook for the full year, sending its stock 6.1% higher Thursday. The retailer saw growth in its core domestic business as well as online operations, marking the 20th consecutive quarter of sales gains in the U.S.

"The economic data this morning are having a calming effect on the equity markets," said Larry Adam, chief investment officer of Raymond James' private client group. "Yesterday with all these growing fears of a global recession including the U.S., those numbers today showed the consumer particularly continued to be fairly robust here."

The Dow fell 800 points, or 3%, on Wednesday for its biggest drop of 2019 amid a recession signal from the bond market. The yield on the benchmark 10-year Treasury note briefly broke below the 2-year rate. The inversion of this key part of the yield curve has been a reliable indicator of economic recessions.

As of Thursday, the curve hovered around the inversion point. Meanwhile, the yield on the 30-year Treasury bond also fell to a new historic low and the 10-year Treasury yield hit its lowest in three years. Investors have piled into long-duration government bonds amid geopolitical uncertainties and a global slowdown this week.

"The 2-10 inversion is sending a massively negative signal that stocks are having a difficult time ignoring," Adam Crisafulli, a J.P. Morgan managing director, said in a note Wednesday.

Somewhat positive trade news also helped the tone on Thursday. A spokesperson at China's Ministry of Foreign Affairs said Beijing "hopes the U.S. will meet China halfway" on trade issues, fueling optimism about a resolution between the two countries.

That came after China said it has to take necessary countermeasures for the latest U.S. tariffs on $300 billion of Chinese goods, adding the U.S. tariffs violated the consensus reached by the leaders of the two countries.

"The market is confused about what the likely outcome is," said Brent Schutte, chief investment strategist at Northwestern Mutual. "In the past there's been pronouncements of positive steps that led nowhere, which I think leads the market to still be skeptical."

This week, President Donald Trump decided to delay tariffs on certain Chinese goods while outright removing some items from the tariff list, a move to avoid any negative impact on the holiday shopping season. The announcement sent the Dow rallying more than 300 points on Tuesday. Those gains were lost in the big sell-off Wednesday.

The deferral "helps China more than us, but will be reciprocated," Trump said Wednesday.

Cisco shares plunged 8.6% Thursday after it said future earnings would be lighter than expected because of a "significant impact" from the U.S.-China trade war. The tech giant also said China revenue fell 25% last quarter on an annualized basis.

Shares of General Electric dropped 11.3%, the most in 11 years, after Madoff whistleblower Harry Markopolos said he has discovered "an Enronesque business approach that has left GE on the verge of insolvency."

— CNBC's Brian Sullivan and Eustance Huang contributed to this report.