The stock market rose Friday, with all three major benchmarks higher, after Moscow agreed to talks with Ukrainian leadership.

Investors continued to buy the dip across markets, wading back into risky assets from shares of rapidly growing companies to bitcoin. U.S. stock indexes soared, outpacing the gains from Thursday’s dramatic midsession rebound and capping a turbulent week for the market.

Stocks...

The stock market rose Friday, with all three major benchmarks higher, after Moscow agreed to talks with Ukrainian leadership.

Investors continued to buy the dip across markets, wading back into risky assets from shares of rapidly growing companies to bitcoin. U.S. stock indexes soared, outpacing the gains from Thursday’s dramatic midsession rebound and capping a turbulent week for the market.

Stocks got a boost after a Kremlin official said that Moscow was willing to send a delegation to Belarus to meet with Ukrainian officials, suggesting Russian President Vladimir Putin remained open to negotiations. The Dow Jones Industrial Average added about 760 points, on pace for its best day of the year, while the S&P 500 gained 1.8%. The Nasdaq Composite advanced 0.9%.

Investors poured about $3.6 billion into U.S. stock ETFs for the week through Thursday, with more than $3 billion going into the broad SPDR S&P 500 ETF Trust, according to FactSet.

Bitcoin, meanwhile, gained 2.5%, as the cryptocurrency moved back toward $40,000. Oil prices fell. Investors sold bonds, pushing the yield on the benchmark 10-year U.S. Treasury back above 2%. Other safe-haven assets, such as gold and silver, fell.

Still, investors say they remain on edge and are bracing for further turbulence. Even after Moscow suggested it was open to negotiations, 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,” he said.

Russian President Vladimir Putin arriving at a meeting in Moscow on Friday.

Photo: Alexei Nikolsky/Associated Press

The stock market’s gains over the past two days helped it make a full recovery from losses earlier in the week. On Monday, while markets were closed for a holiday, Mr. Putin deployed troops into an eastern region of Ukraine. Stocks sold off sharply Tuesday, 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.

By Tuesday’s close, the S&P 500 shed 1%, leaving it down more than 10% from its early-January record in its first correction in more than two years. The selling continued into Wednesday and most of Thursday as Russia began its invasion of Ukraine. However, stocks staged a turnaround midday Thursday after President Biden

outlined additional sanctions on Russia.

Other markets have also been roiled by the conflict. Before falling Friday, oil prices reached their highest level in nearly a decade. Wheat futures also have surged.

For investors in the U.S., two questions have emerged that will largely dictate the path of stocks and other assets over the course of the year. First is whether Russia’s invasion of Ukraine will escalate to a point that the U.S. is somehow pulled into direct conflict. The other is what impact all of this will have on commodity prices, inflation and the Fed’s plan to raise interest rates in an effort to counter inflation.

Greater involvement by the U.S. against Russia would inevitably weigh on stocks, analysts said, with some adding that the risk of that seems relatively low at the moment. Analysts appear more split on how the Fed will proceed, with some predicting the central bank will take a more dovish approach and others saying the conflict in Ukraine could force the Fed and other central banks to lift rates even faster than expected.

“Ultimately, the long-term path for risk assets will remain broadly unaltered,” said

Seema Shah, chief strategist at Principal Global Investors. “A modest path higher—but one that could be hit with significant volatility and uncertainty.”

So far, investors have responded positively to stiffening restrictions on Russian companies and individuals, with markets either recovering some losses or outright rallying after the unveiling of sanctions this week. 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, with groups gaining anywhere between 1% and 3%.

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 1.3%, while Google parent

Alphabet gained 1.5%. Financial stocks added more than 3%, while consumer staples rose 2.9%. Both remain down slightly for the week.

Stocks rebounded overseas, too. 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 3.3%, but remained down 1.6% for the week. Japan’s Nikkei 225 rose 1.9%, and the CSI 300, which comprises the largest stocks listed in Shanghai and Shenzhen, both rose 1% after falling 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 and Michael Wursthorn at michael.wursthorn@wsj.com.