U.S. stocks finished lower after failing to defend intraday gains Wednesday as investors struggled to adjust to an investment environment marked by both rising bond yields and signs of inflation.

The market’s move south coincided with a spike in the 10-year Treasury yield in the wake of the news of a two-year budget deal announced by top senators that would significantly raise fiscal spending.

Recent trading has seen huge swings in both directions, though the dominant move over the past week has been lower, something analysts said was to be expected after Wall Street scored big gains in January and throughout 2017.

Check out:Why the Dow has suddenly become a hot mess

How did the main benchmarks fare?

The Dow Jones Industrial Average DJIA, -0.87% slid 19.42 points to 24,893.35, after bungee-jumping a 500-point range during the session.

The S&P 500 SPX, -1.11% fell 13.48 points, or 0.5%, to 2,681.66, with energy and technology sectors leading the losers. The Nasdaq Composite COMP, -1.07% shed 63.90, 0.9%, to 7,051.98.

At current levels, major indexes stand about 5% below last month’s record highs.

The yield on the 10-year Treasury note TMUBMUSD10Y, 0.701% jumped to 2.84% after trading as low as 2.75% earlier.

Read:50-year Wall Street veteran says this sure feels like a stock-market bottom

And see:Here’s how U.S. stocks typically perform in the aftermath of a major rout

What drove the markets?

Congressional leaders reached an agreement on a two-year budget pact that would increase fiscal spending by $300 billion on the back of a big increase in military spending. The deal, which still needs to be approved by the Congress, is at least likely to put to rest fears of another government shutdown.

Trump: 'I'd love to see a shutdown'

There were no top-tier economic reports Wednesday but New York Fed President William Dudley took part in a panel discussion on banking culture during which he said the recent drop in the stock market wasn’t big enough to alter the economic outlook.

Separately, Chicago Fed President Charles Evans said there is “a hint” of inflationary pressure in recent economic reports but not many actual increases in consumer prices. As such, the central bank can hold off raising rates until “midyear or so” in order to assess the incoming inflation data. Evans is not a voting member of the Fed’s interest-rate committee this year and he has been a leading dove among his colleagues.

Check out:MarketWatch’s Economic Calendar

What were strategists saying?

Jack Ablin, chief investment officer at Cresset Wealth Advisors, said there are three types of market pullbacks — technical, cyclical and systemic — and he believes the current selloff is technical in nature.

“Market valuations are expensive and need to correct. At the same time, credit conditions remain robust as the availability of money to borrow, spend and invest is strong,” Ablin said in a note to investors. “While it’s impossible to predict where the markets will meander on a day-to-day basis, we are confident that any pullback that plays out over the next few weeks represents a better opportunity to buy for the long run rather than a reason to sell.”

“The market was positioned for great earnings, great growth, and no inflation or rates moving up to any meaningful degree. Now that goldilocks environment is gone, and we’re back in a normal environment where we’re getting both strong growth and higher rates. That readjustment is bringing some jitters,” said Alec Young, managing director of global markets research at FTSE Russell.

“We’re still in an environment with synchronized global growth — no one is talking about a recession right now — but the days of smooth sailing where the market goes up every day are probably over.”

Which were the key stock-market movers?

Shares of Snapchat parent Snap Inc. SNAP, -1.97% surged 48% after better-than-expected quarterly results late Tuesday.

See: A year after IPO, Snap shows progress but still has many issues

Walt Disney Co.’s stock DIS, -1.22% reversed early gains to drop 1.3% after the entertainment giant reported stronger-than-anticipated earnings late Tuesday.

Chipotle Mexican Grill Inc. CMG, -0.80% tumbled 11% even as the burrito chain’s profit topped forecasts and revenue met expectations.

See:With Fox merger and ESPN streaming effort, Disney has a confusing mess

Wynn Resorts Ltd.’s stock WYNN, -2.01% rose 8.6% after Steve Wynn resigned late Tuesday as chief executive and chairman following allegations of sexual misconduct.

Shares in Tesla Inc. TSLA, +4.42% rose 3.3% as the maker of electric cars is scheduled to post earnings after the bell. On Tuesday, a Tesla Roadster was launched into space as dummy payload (and as a publicity stunt), sending shares 2% higher.

See:SpaceX successfully launches massive Falcon Heavy rocket

Media company Tronc Inc. US:TRNC jumped 19% after announcing its sale of the Los Angeles Times and the San Diego Union-Tribune for $500 million to businessman Patrick Soon-Shiong.

Shares in Hasbro Inc. HAS, -0.62% rallied 8.8% after the toy maker beat fourth-quarter profit expectations but missed on revenue.

How did other assets perform?

European stocks SXXP, -0.66% closed modestly higher, while Asian markets finished mixed after earlier gains faded. Gold US:GCG8 settled lower and oil futures US:CLH8 fell 2.7%. The ICE U.S. Dollar Index DXY, +0.03% gained 0.8%.

—Victor Reklaitis contributed to this report