A group of Canadian banks on Friday appeared close to finalizing a little-known agreement that likely prevents a selloff of as much as $260 billion in highly levered debt, narrowly avoiding what might have been a major hit to U.S. credit markets.

The banks on late Thursday appeared to have held together the Montreal Accord, which aims to restructure some $33 billion in asset-backed commercial paper acting as collateral on U.S. investment-grade bonds, according to the Toronto Globe and Mail. The value of that collateral, like many other kinds of debt, has plummeted in recent trading in the intensifying credit crisis and the banks had agreed to temporarily suspend their right to trigger defaults while they work out a deal.

The tentative agreement is awaiting a judge's approval, the Globe and Mail reported. The banks, including Bank of Montreal ( BMO - Get Report), Royal Bank of Canada ( RY - Get Report) and Toronto-Dominion ( TD - Get Report) agreed to back a credit line to support the restructuring, the paper said. A framework to swap the frozen paper for more liquid, longer-terms notes existed for months, but the deteriorating credit market made finalizing the deal difficult, the paper said.

Speculation this week sent the investment grade market into turmoil as rumors that Bank of Montreal was close to pulling out of the agreement. That could have triggered a mass selloff of the bonds, as highly levered margin bets are unwound to the tune of as much as $260 billion, said Daryl Ching, Managing Partner of Clarity Financial Strategy. Ching called that possibility "catastrophic."

Bank of Montreal declined to comment on the rumors earlier this week, but confirmed its participation in the Accord Friday.

The tenuous situation was reflected this week in the IG9 index, which measures default protection costs for 125 U.S. and Canadian investment grade companies. According to interdealer broker Phoenix Partners Group, the index, reached 194 on Monday, up sharply from 177 on Friday and its highest level ever. To put this in perspective, the IG9 was at a level of 80 as recently as Jan. 2. The spread widens as the deterioration increases.

"We have not seen this since the 1980s," Ching said. "The volatility is quite scary."

If the restructuring agreement had collapsed, then the holders of the bonds would have been forced to liquidate in a distressed market, driving down their value, Ching said.

The noteholders of the asset-backed commercial paper agreed to not dump the seriously devalued product on the market, if they could get out with at least the principle. The banks were to agree to not make margin calls to help out the noteholders. If the banks made the margin calls, the noteholders more than likely wouldn't have been able to pay them and would have had to unload the instruments even though no one wants to buy them -- including the very banks that sold them.

The domino effect is that the asset-backed commercial paper was used as collateral to buy U.S. investment grade bonds. With the collateral gone, the investment grade bonds will also be released into the market. Just this week Carlyle Capital was forced to admit it couldn't make its margin calls and gave its unwanted paper to its creditors.

"The value of the collateral has gone down and more margin is required," said Michael Goldberg of DesJardins Securities.

While a bullet may have been dodged, questions remain over the value of the assets backing this commercial paper. JPMorgan Chase ( JPM - Get Report), an advisor to the banks in the Accord, supposedly values the assets at 80 cents on the dollar, but one trader contacted by TheStreet.com questions that price. Once the restructured notes hit the market, interest isn't expected that demand will be great, the trader said.