Updated from July 17.

Merrill Lynch

(MER)

posted a second-quarter loss far beyond Wall Street expectations on Thursday, as the bank sold its stake in Bloomberg LP back to the financial information provider to shore up capital.

Merrill reported a loss of $4.7 billion, or $4.97 per share, driven by its exposure to risky structured finance, residential mortgages and investments in the U.S. banking sector. It is the firm's fourth consecutive quarterly loss, comparing to net earnings of $2.1 billion, or $2.24 per share, a year earlier. Analysts had expected a loss of $1.91 per share, on average.

Merrill posted $9.4 billion in writedowns and impairment charges, with negative net revenue of $2.1 billion. That figure compares with a positive $9.5 billion a year earlier.

Its stock -- which had risen nearly 10% over the course of Thursday -- lost ground in after-market trading following the announcement. Recently, shares were shedding 1.9% to $30.16 in premarket trading.

Better-than-expected results at

JPMorgan Chase

(JPM) - Get Report

and

Wells Fargo

(WFC) - Get Report

had supported bank stocks on Wednesday and Thursday, but Merrill's bleak report was a reminder of the housing and credit-related problems the financial sector continues to face.

Merrill lost $3.5 billion on U.S. super-senior asset-backed collateralized debt obligations, as well as $2.9 billion on credit-valuation adjustments, much of which was related to hedges on those CDOs. It also lost $1.7 billion from investments in U.S. banks and $1.3 billion from residential real-estate exposures.

Merrill sold its 20% interest in Bloomberg back to the company for $4.43 billion. News of the sale

first leaked

on Wednesday. Merrill also said it is in negotiations to sell its Financial Data Services subsidiary for more than $3.5 billion. That business provides administrative services for mutual funds, retail banking and wealth management.

"This was obviously a difficult and disappointing quarter for us in terms of our bottom line," CEO John Thain told conference-call listeners after the report was released. He noted that the firm is working toward better risk management and other growth initiatives and that despite negative revenue, Merrill has "more than replaced" the capital it has lost over the past two quarters.

Nonetheless, Moody's downgraded the investment bank's senior long-term debt one notch to A2 from A1, due to its "fourth consecutive quarter of sizeable losses" and estimated that the firm could take an additional $10 billion in pre-tax write-downs from CDOs and mortgages. Its outlook for the firm is stable.

Standard & Poor's, which downgraded Merrill's debt last month, held its ratings steady at A and A-1 with a negative outlook. Credit analyst Scott Sprinzen said the firm's write-downs and charges were "greater than we had previously anticipated."

Fox-Pitt Kelton Cochran Caronia Waller analyst David Trone on Friday downgraded Merrill to underperform from in-line and wrote "the outlook for Merrill's equity is getting dicey."

While the firm still has its 49% interest in investment management firm

BlackRock

(BLK) - Get Report

to sell if it needs to shore up capital further, that may yield only up to $2.5 billion, Trone wrote. If Merrill continues to post quarterly losses of the second quarter's magnitude, it may have to resort to selling other businesses to cover holes.

"That

management has to hold a yard sale to keep Merrill afloat is troubling enough, and now the margin for error for equity holders is getting precariously thin," he wrote Friday morning.

Merrill reduced risk-weighted assets by 27% over the quarter, though Thain noted on the conference call that "to cut your leveraged-loan book in half is not the easiest thing to do in this environment." He said that while the firm is eager to shed trouble assets, Merrill will not sell them at prices that are too low.

"I don't think we want to do dumb things," Thain said. "I think we have been pretty balanced in terms of what we sold and at what prices we sold them, we have not simply liquidated stuff at whatever prices we could get."