U.S. stocks clawed back from early losses to close higher Friday after key negotiators cast a positive glow on trade talks. But the S&P 500 and the Nasdaq logged their worst week of 2019 as tensions between the U.S. and China remain elevated in the wake of the Trump administration’s move to raise import duties on $200 billion in Chinese goods.

The Dow Jones Industrial Average DJIA, +0.56% rose 114.01 points, or 0.4%, to end at 25,942.37, recovering from a deficit of more than 350 points. The S&P 500 index SPX, +0.60% gained 10.68 points, or 0.4%, to 2,881.40, while the Nasdaq Composite Index COMP, +0.67% climbed 6.35 points, or 0.1%, to 7,916.94.

For the week, the Dow fell 2.1%, its biggest weekly loss since March. The S&P saw a 2.2% weekly fall and the Nasdaq shed 3%, the biggest losses for both since the week ending Dec. 21.

What drove the market?

Trade tensions were front and center as the U.S. increased tariffs as of 12:01 Eastern time Friday, with Beijing vowing to retaliate.

But the stock market bounced back after U.S. Secretary of Treasury Steven Mnuchin indicated that bilateral talks were “constructive” even though an agreement was not reached. The optimistic tone was reinforced by President Donald Trump in a tweet soon after.

Trump had voiced frustration over the pace of talks with China in recent days, with the president accusing Chinese officials of reneging on commitments made in previous negotiations.

See:Here’s how hard the U.S.-China tariff fight will hit the economy

The president also threatened Friday morning on Twitter that his administration was taking steps to impose new 25% tariffs on the remaining $325 billion in annually imported goods from China. In a series of tweets, the president continued to defend tariffs, writing that they will “make our country much stronger, not weaker. Just sit back and watch.”

Read: Here are the stocks to buy if an all-out U.S.-China trade war erupts, says Goldman

What economic data and speaker were in focus?

Consumer prices rose 0.3% in April, below the 0.4% level expected by economists, according to a MarketWatch poll. Core inflation, which excludes volatile food and energy prices, rose 0.1% in April, below the 0.2% consensus estimate.

Atlanta Fed President Raphael Bostic said in a meeting with business leaders in Meridian, Mississippi, that the central bank might have to cut interest rates if the new round of tariffs placed on Chinese goods causes consumer spending to suffer.

New York Fed President John Williams said that recent core inflation readings “are a touch too low,” but so far “appears mostly to reflect normal volatility” in the statistics. In a speech, he said that current monetary policy “was in the right place” but that Fed officials will be watching inflation statistics closely to see that they rise to meet the central bank’s 2% goal.

What were strategists saying?

“Despite the tariff increase, the outlook for a trade deal in the relatively near future remains cautiously optimistic,” wrote Tom Essaye, president of the Sevens Report, in a note to clients, pointing out that negotiations continue, along with the fact that the Trump administration included a ‘grace period’ in the most recent tariff hikes.

“Goods currently in transit to the U.S. from China aren’t subject to the new 25% tariffs, just the old 10% tariff. That grace period was not included in previous rounds of tariffs and is likely an olive branch of sorts to the Chinese side,” he added. “Given shipping times, goods sent from China today will take two weeks or so to reach the U.S., so if a trade deal is stuck in that time frame, the pain of the 25% tariffs will never be felt.”

“Best guess now is that both sides talk Friday and then pause for a rethink of how to proceed. If so, we are in for a period of high uncertainty. But we need to await the outcome of Friday’s talks to make closer assessment,” said analysts at Danske Bank in a note to clients.

See:Why the tariff fight prompted a major wealth manager to change its U.S. portfolios

What stocks were in focus?

Uber Technologies Inc. UBER, +0.08% shares slumped 7.6% to $41.57 after the company’s debut on the New York Stock Exchange. The ride-hailing firm priced its IPO on Thursday afternoon at $45 a share, which is expected to raise the company at least $8 billion.

Shares of Symantec Corp. US:SYMC sank 13% after the firm reported an earnings miss and downbeat guidance on Thursday evening, and said that CEO Greg Clark had left his role.

Shares of Viacom Inc. US:VIAB rose 2.6% after the entertainment content company reported fiscal second-quarter earnings that beat expectations, but a wider decline in revenue than Wall Street had expected.

How were other markets trading?

Chinese benchmarks soared, with the Shanghai Composite Index SHCOMP, -1.72% gaining 3.1% and the Shenzhen Composite Index 399106, -2.45% surging 3.8%. However, Japan’s Nikkei 225 index NIK, -1.10% finished off 0.3%.

Meanwhile, Europe’s Stoxx Europe 600 Index SXXP, -1.02% rose 0.3%.

Gold US:GCM9 settled higher, while the U.S. dollar edged lower DXY, -0.11% and crude oil futures US:CLM9 posted a mixed finish.

—Barbara Kollmeyer contributed to this article