U.S. stocks declined and oil prices jumped, as concerns about rising energy prices, supply shortages and inflation rattled investors once again.

The S&P 500 ticked down 1.23%, or 55.37 points, to close at 4456.24, while the Dow Jones Industrial Average fell 1.29%, or 448.96 points, to 34358.50. The blue-chip index is 6.6% off the record close it hit on Jan. 4 and down 5.4% for the year. The tech-focused Nasdaq Composite Index slid 1.3%, or 186.21 points, to 13922.60.

The declines followed sharp gains by major U.S. stock indexes Tuesday as investors shrugged off worries that inflation will push the nation’s economy into a recession. On Wednesday, however, some of that confidence faded after Brent crude, the international oil benchmark, moved higher again.

Futures on Brent crude gained $6.12 a barrel, or 5.3%, to $121.60, the third-highest settlement value of the year and the highest since March 8. Brent crude has surged 56% this year amid an expanding global economy as the coronavirus pandemic waned and concerns about supplies due to Russia’s invasion of Ukraine.

Adding to those concerns Wednesday: Russia said on Tuesday that oil exports via a pipeline from Kazakhstan to the Black Sea may temporarily fall by around 1 million barrels a day—representing about 1% of global oil demand—citing storm damage. Repairs could take up to two months, Russian officials said.

“Things will stay highly sensitive to the events unfolding in Ukraine,” said Susannah Streeter, senior investment and markets analyst at Hargreaves Lansdown, noting that sharp moves in energy prices will continue to weigh heavily on indexes. “There is still real pressure on oil prices that is adding to inflationary concerns.”

Commodities snapped higher across the board on a range of issues that threatened to pinch supply chains. Comex copper gained 1.6% to $4.76 a pound, its fifth-highest close ever, leaving it up 6.9% for the year.

Aluminum, nickel and steel prices also rose on concerns ranging from the war in Ukraine to Covid-19 lockdowns in China. Tangshan, the biggest steelmaking city in China, told residents to stay home due to a Covid-19 surge, according to Reuters. The city accounts for 58% of China’s strip-steel output, London commodity broker SP Angel said in a Wednesday note.

“Inflation is still the 800-pound gorilla,” said Doug Sandler,

global head of strategy at RiverFront Investment Group. The concern is that rising prices will force the Federal Reserve to raise rates faster than investors had previously expected, he said.

Mr. Sandler said his firm started paring back its stockholdings earlier this year amid concerns about a riskier, more uncertain environment for the U.S. and global economies. The hope, he said, is that supply-chain issues that have pushed up the price of everything from corn to copper will work themselves out in the coming months, reducing the need for sharply higher fed-funds rates.

A sharp rally in U.S. government bond yields paused. The yield on the 10-year U.S. Treasury note edged lower to 2.320%, from 2.375% the day before. Yields on U.S. government bonds zoomed higher this week after Fed Chairman Jerome Powell said the central bank was prepared to raise interest rates in half-percentage-point steps if needed to tame inflation. Yields climb when bond prices fall.

Other signs emerged Wednesday that investors were eyeing assets they perceive as safer. The WSJ Dollar index, which tracks the currency against a basket of others, rose 0.11%. Gold advanced 0.8%. 

Russia’s stock market is set for a partial reopening Thursday, almost a month after it closed following the country’s invasion of Ukraine. Investors and analysts expect that the reopening could send Russian stocks into free fall.

In recent days, global markets seemed to have turned a corner, despite anxieties about mounting inflation and the war in Ukraine. The recent rally has come even as Russia’s attacks on Ukraine intensify, Western countries continue to pile on sanctions and pricing pressures show no signs of abating. On Wednesday, fresh data on inflation showed that consumer prices in the U.K. rose 6.2% in February compared with a year earlier, up from 5.5% in January, marking the highest rate since March 1992. 

Fari Hamzei, of Hamzei Analytics, said the recent bounce in stocks has come on low volume, indicating it could be a so-called bear-market rally.

Mr. Hamzei is looking for a few days of large drops in which 90% of New York Stock Exchange stocks decline, which would signal a buying opportunity. On Wednesday, about 4.54 billion shares changed hands on the New York Stock Exchange, the lowest volume since Feb. 16.

“We haven’t seen capitulation,” he said. “You need volume to confirm the price action.”

Sharply higher oil prices could trigger such a decline. Mr. Hamzei expects WTI crude oil, Brent’s U.S. counterpart, which closed up 5.2% to $114.93 Wednesday, to surge to between $135 or $145 a barrel. A significant escalation of the conflict in Ukraine, he said, could also push investors out of stocks.

Higher oil prices could spark more consumer interest in electric vehicles, analysts said. Shares of Tesla gained 0.5%, or $5.13, to $999.11, marking a gain in seven straight days of trading, a run that has powered the EV maker 30.4% higher in that time period.

Meanwhile, shares of meme stocks—which have largely slumped this year—enjoyed a resurgence. Shares of GameStop climbed 14.5%, or $17.86, to $141.00, after the company’s chairman, Ryan Cohen, disclosed his firm bought 100,000 shares of the company’s stock on Tuesday. Shares of AMC Entertainment Holdings, which tend to move in correlation with GameStop, climbed 13.6%, or $2.48, to close at $20.74.

Shares of Adobe slumped 9.3%, or $43.55, to $422.90. The software company reported higher profit and better-than-expected revenue growth Tuesday, but said it expects a hit to annual revenue from the war in Ukraine.

Traders worked on the floor of the New York Stock Exchange on Tuesday.

Photo: BRENDAN MCDERMID/REUTERS

In European markets, the Stoxx Europe 600 lost 1.1%, erasing earlier gains once oil prices moved solidly higher. London’s FTSE 100 nudged down 0.1%.

In Asia, major indexes finished higher. Hong Kong’s Hang Seng gained 1.2%, while Japan’s Nikkei 225 jumped 3%. China’s Shanghai Composite advanced 0.3%.

—Georgi Kantchev contributed to this article.

Write to Caitlin McCabe at caitlin.mccabe@wsj.com and Scott Patterson at scott.patterson@wsj.com