By Elisabeth Buchwald, CNN

New York (CNN) — Markets will want to breathe a sigh of relief if lawmakers can reach a deal on the debt ceiling to avoid a default. But markets can’t always get what they want.

The stock market, for the most part, has been ignoring the serious risks associated with the United States defaulting on its debt. But as the Treasury Department’s June 1 estimated default date nears, the stock market is poised to start taking note.

Even once a deal is reached, it could take months before stocks and other financial markets move on.

“One of the concerns I have is that even in the run-up to an agreement, when one does occur, there can be substantial financial market distress,” Treasury Secretary Janet Yellen said on Wednesday.

“We’re seeing just the beginnings of it,” she said, referring to stock and bond market volatility in recent days.

Immediate market impact of a debt ceiling deal

If markets get what they ultimately want — no debt default — they’ll have to buckle up for a potentially rough ride immediately after a deal is signed.

That’s because the Treasury will instantly need to replenish the cash it burned through during the period of extraordinary measures when it could not borrow more money.

This will create more competition for equity from investors, said Michael Reynolds, vice president of investment strategy at Glenmede. After weighing their options, many investors may find the returns from investing in US Treasuries better than stocks. That will temporarily suck some liquidity out of the stock market, he said.

A look back at the 2011 debt ceiling crisis

In 2011, lawmakers came to an agreement on raising the debt limit just hours before the United States would have defaulted. Two days later, Standard & Poor’s downgraded US debt for the first time in history.

It took two months for stocks to recover the losses resulting from the downgrade and the initial sell-off leading up to the X-date.

Could history repeat itself?

“It wouldn’t be surprising if the 2011 pattern repeats again,” said George Mateyo, chief investment officer at Key Private Bank.

While he doesn’t expect a major credit agency to downgrade US debt before or after a deal to raise the debt ceiling is reached, he said the current standoff could lead to a big loss of confidence in America’s financial system.

That’s why he’s anticipating monthslong market volatility even once a deal is reached.

“Just because we get the debt limit raised, we’re not out of the woods,” Mateyo told CNN.

™ & © 2023 Cable News Network, Inc., a Warner Bros. Discovery Company. All rights reserved.