Phew! That was close!

After dipping deep into the single digits last week, Morgan Stanley (NYSE:MS) shares have surged more than 80% so far today. A $9 billion capital infusion that looked like it was on the rocks last week has been set in stone, laying worries of a looming collapse to rest.

Morgan Stanley will sell 21% of itself to Mitsubishi UFJ Financial Group of Japan in exchange for $7.8 billion of convertible preferred shares and $1.2 billion of non-convertible preferred shares, both yielding a fat 10%. As an unmentioned part of the deal, Morgan Stanley gets another shot at life.

The Wall Street bank got absolutely obliterated in last week's trading. Investors -- already scared out of their wits by the market's mayhem -- feared the deal would fall apart, after shares plummeted from the price at which terms were originally struck. Concerns swirled that Mitsubishi would either walk away, or that the original $9 billion investment would be renegotiated to something representing far more than a 21% stake, creating a serious dilution for existing investors. The result was a vicious cycle: Shares fell out of fear the deal was falling apart, and the deal could have fallen apart because shares were plunging.

Thankfully, everyone came out a winner here, at least compared to last week's bloodbath. Rather than renegotiate the amount of the company Mitsubishi will effectively own, Morgan Stanley sweetened the terms by lowering the conversion price on the convertible shares, and offered preferred shares in lieu of the common stock. In return, Morgan Stanley got a slug of cash it can use to rebuild its balance sheet, amid the possibility that raising capital in the future might be much easier said than done.

Will it work? We sure hope so, but the history of large capital injections into financial companies over the past year has pretty much been 0 for 3. Singapore injected $5 billion into Merrill Lynch (NYSE:MER) late last year, only to watch it stumble into the arms of Bank of America (NYSE:BAC). The Chinese government invested $3 billion into Blackstone (NYSE:BX) last year, only to watch shares fall almost 75% from the price at which they went public. Private equity firm TPG Capital invested $7 billion in Washington Mutual back in April ... and we all know how that ended up.

In the coming years, Mitsubishi will either look like a genius or a sucker for its huge stake in Morgan Stanley. On one hand, shares might look ridiculously cheap, priced on nothing more than fear; on the other hand, Morgan Stanley's switch to a bank holding company means many of the lucrative income streams it relied on in recent years are a thing of the past. The big question Mitsubishi must ask now is whether the old Morgan Stanley will look even remotely close to the new one.

For related Foolishness: