U.S. stocks closed higher Tuesday, with the Nasdaq extending its winning streak to a seventh session, as another round of U.S.-China trade talks began in Washington. The market’s gains were led by so-called defensive sectors such as utilities and consumer staples, which are less sensitive to economic cycles.

The Dow Jones Industrial Average DJIA, +0.51% rose 8.07 points to 25,891.32 and the S&P 500 index SPX, +1.05% climbed 4.16 points, or 0.2%, to 2,779.76. The Nasdaq COMP, +1.71% advanced 14.36 points, or 0.2%, to 7,486.77, logging its longest stretch of gains since the index rose for eight straight days in August.

What drove the market?

Recent gains were fueled, in part, by upbeat expectations surrounding U.S.-China trade negotiations held in Beijing. Talks resumed this week in Washington, sparking hopes that the two sides can continue to make progress toward a deal.

President Donald Trump on Sunday tweeted about the trade talks, saying “Big progress being made on soooo many different fronts!”

Investors appeared to pay little attention to Trump’s declaration of a national emergency to pay for a wall along the U.S.-Mexico border. Sixteen states filed a federal lawsuit on Monday challenging the declaration.

Even as the Trump administration seeks a resolution to the standoff over U.S.-China trade relations, investors are also being forced to weigh the implications of a new study submitted Sunday to the White House by the Commerce Department concerning the imposition of new tariffs on auto imports on national-security grounds.

The recommendations contained in the report have yet to be made public, and the administration has 90 days to decide whether to implement the study’s proposals.

Cleveland Federal Reserve Bank President Loretta Mester told an audience Tuesday at the University of Delaware that she expects economic growth and job growth to slow this year compared with last, but that she expects growth to be strong enough that the fed-funds rate “may need to move a bit higher than current levels.”

The National Association of Home Builders monthly confidence index rose 4 points to a seasonally adjusted rate of 62 in February, a four-month high, the association said.

What were analysts saying?

“We’ve had a market that has priced in a lot of good news,” Marvin Loh, global macro strategist at State Street, told MarketWatch, adding that markets rallied recently on optimism surrounding trade talks.

“This could be one of those ‘buy the rumors, sell the fact’ sort of situations,” in which much of the trade-talk related gains for stock markets are already in the rearview mirror, he said.

“After the boost received from upbeat headlines with regards to last week’s U.S.-China trade talks, risk appetite eased somewhat, with negotiations set to continue in Washington this week,” wrote Charalambos Pissouros, senior market analyst with JFD Brokers, in a note. “Concerns over a potential escalation between the U.S. and the EU with regards to auto tariffs may have been one of the reasons behind the slightly softer investor morale.”

What stocks were in focus?

Shares of Dow component Walmart Inc. WMT, +0.90% climbed 2.2% after the retailer reported fourth-quarter earnings and revenues that surpassed Wall Street expectations, while raising its annual dividend by 2%.

Advance Auto Parts Inc. AAP, +1.13% shares slid 1.7% after the firm reported fourth-quarter profits that topped analyst forecasts but saw same-store sales growth fall short.

Shares of Medtronic Plc MDT, -0.42% edged up 0.1% after the medical device manufacturer reported fiscal third-quarter profits and sales that beat analysts’ forecasts.

Weight Watchers International Inc. US:WTW shares dropped 4.5% after the stock was downgraded to underweight from neutral at J.P. Morgan, which also cut its price target on the stock to $25 from $37.

How did other markets trade?

Stock markets in Asia ended mixed, with Japan’s Nikkei 225 NIK, -0.05% edging 0.1% higher, while China’s Shanghai Composite Index SHCOMP, +0.16% lost 0.8% and Hong Kong’s Hang Seng Index HSI, +0.10% fell 0.4%.

In Europe, stocks were lower, with the Stoxx Europe SXXP, +1.46% down 0.2%.

Crude oil prices US:CLH9 and the price of gold US:GCH9 strengthened while the value of the dollar DXY, -0.03% , relative to its peers, declined.

—William Watts contributed to this report