The stock market rose Friday after Moscow agreed to talks with Ukrainian leadership, capping a turbulent week for major stock indexes.

The S&P 500, already reeling from fast-rising prices and central banks’ plans to tighten monetary policy, was rocked this week by the spiraling conflict in Eastern Europe. Escalating tensions between Russia, Ukraine and most other Western nations earlier in the week threw the broad benchmark into its first correction in two years.

Even…

The stock market rose Friday after Moscow agreed to talks with Ukrainian leadership, capping a turbulent week for major stock indexes.

The S&P 500, already reeling from fast-rising prices and central banks’ plans to tighten monetary policy, was rocked this week by the spiraling conflict in Eastern Europe. Escalating tensions between Russia, Ukraine and most other Western nations earlier in the week threw the broad benchmark into its first correction in two years.

Even after a stunning rebound on Thursday followed by sharp gains Friday, the S&P 500 remained flat over the last four days of trading.

Other markets were also roiled, as investors pondered how the fighting, its effect on commodity markets and retaliatory Western sanctions will ripple through a world economy already grappling with elevated inflation and coming interest-rate increases by the Federal Reserve and other major central banks.

Oil prices reached their highest level in nearly a decade, while wheat futures surged. Investors mostly sold government bonds, pushing the yield on the benchmark 10-year U.S. Treasury note back above 2%.

Stocks, for their part, continued their volatile run into the week’s end. The S&P 500 added 1.5% Friday, building on the index’s 1.5% gain from a day earlier. The Dow Jones Industrial Average added more than 550 points, while the Nasdaq Composite rose 0.8%.

The left the S&P 500 little changed over the last four days of trading. The Dow was off 0.8% during that period, while the Nasdaq was up 0.2%.

Despite the gains, investors say the situation in Ukraine appears far from resolved, making the conflict and the potential for escalation another variable investors need to weigh in the months ahead. Even after Moscow suggested it was open to negotiations by sending a delegation to meet with the Ukrainian government Friday, Kyiv came under renewed bombing and land attacks.

“I do not think that this highly volatile period is already coming to an end,” said

Daniel Egger,

chief investment officer at St. Gotthard Fund Management. “Right now we have to focus now on what’s happening in Kyiv, how bloody the coming days will be, and I would say definitely the Russian sanctions still can be stepped up.”

On Friday, all three stock benchmarks rose after a Kremlin official said that Moscow was willing to send a delegation to Belarus to meet with the Ukrainian officials, suggesting Russian President
Vladimir Putin

remained open to negations.

That helped recoup losses from earlier in the week after Mr. Putin’s decision to deploy troops into an eastern region of Ukraine by triggered a marketwide selloff on Tuesday. The pullback was enough to push the broad benchmark down more than 10% from its early-January record, knocking it into its first correction in two years.

Russian President Vladimir Putin arriving at a meeting in Moscow on Friday.
Photo: Alexei Nikolsky/Associated Press

So far, the U.S. and its allies have laid out stiff restrictions on Russian companies, and the European Union will formally sign off on sanctions Friday that will cut 70% of Russia’s banking system off from global financial markets. Given the scale of Moscow’s attack, investors are preparing for potentially stricter restrictions, such as cutting off Russia from vital international financial infrastructure. 

On Friday, all 11 sectors of the S&P 500 rose, led by shares of consumer staples, healthcare companies and utilities.

Technology stocks, which have played a major role in the market’s twist and turns in recent sessions, continued to accrue gains across the board. Shares of
Apple
added 0.3%, while
Facebook
parent Meta Platforms rose 1.2%.

Overseas, Russia’s Moex stock-market gauge, which tumbled Thursday, rose around 19%. Russia’s ruble gained almost 3% to trade at 82 a dollar, having shed almost 8% Thursday.

The Stoxx Europe 600 rose 2.8%, led by shares of utilities. Japan’s Nikkei 225 rose 2%, and the CSI 300, which comprises the largest stocks listed in Shanghai and Shenzhen, rose 1%, after both fell Thursday. Hong Kong’s Hang Seng Index slipped 0.6%.

In energy markets, futures for Brent crude, the global oil benchmark, edged down 1% to $94.45 a barrel, while European natural-gas prices retreated by more than one-fifth after rocketing Thursday. Brent topped $100 a barrel early Thursday before falling back.

Rapid inflation and the prospect of tighter monetary policy were complicating the outlook for some traditional safe-haven assets such as Treasury bonds, the U.S. dollar and gold, said

Yung-Yu Ma,
chief investment strategist for BMO Wealth Management in the U.S.

In bond markets, the yield on the benchmark U.S. 10-year Treasury note rose to 2.004% from 1.969% Thursday. Yields and prices move inversely. Gold prices slipped 1.8% to $1,891 a troy ounce.

“It looks like the military action in Ukraine could be protracted,” said Mr. Ma, adding that this would make short-term market movement difficult to predict.

Fragments of a downed aircraft seen in Kyiv, Ukraine, on Friday.
Photo: Oleksandr Ratushniak/Associated Press

—Dave Sebastian and Caitlin Ostroff contributed to this article.

Write to Joe Wallace at joe.wallace@wsj.com, Michael Wursthorn at michael.wursthorn@wsj.com and Dave Sebastian at dave.sebastian@wsj.com