NEW YORK (CNNMoney.com) -- Merrill Lynch booked its fourth-straight quarterly loss Thursday, this time losing nearly $5 billion, as the nation's largest brokerage was forced to once again take massive writedowns.

Merrill said it lost $4.9 billion overall. On a continuing operations basis, it lost $4.6 billion, or $4.95 a share, down from a profit of $2.01 billion, or $2.24 a share a year ago. Analysts polled by Thomson Reuters were expecting the company to report a loss of just over $1.8 billion, or $1.91 a share on this basis.

The company has now lost more than $19.2 billion in the past twelve months, making it one of the hardest hit companies during the credit crisis roiling the nation's big financial services firms.

Merrill (MER, Fortune 500) shares plunged about 6% after hours, nearly wiping out the stock's 10% gain in regular trading on the New York Stock Exchange Thursday.

Driving the loss was yet another round of writedowns. Merrill took a $4.8 billion mark on its mortgage-related portfolio, a $2.9 billion writedown due to its exposure to the recently downgraded bond insurers Ambac (ABK) and MBIA (MBI), $1.7 billion in its investment portfolio of U.S. banks and $348 million related to leveraged loans.

That surpassed the nearly $6 billion total that some analysts were anticipating heading into this week's results.

"Is the company a good franchise? It's a very good franchise," said Brad Hintz, senior analyst at Sanford C. Bernstein & Co. "The problem you have is it will be a long time until that balance sheet is clean."

Those marks hit Merrill's global markets and investment banking divisions particularly hard, as it suffered a pre-tax loss of $8.56 billion in the quarter from continuing operations.

Merrill's global wealth management business remained profitable, but its earnings fell 16% from a year ago.

"Our core franchise continues to perform well despite the extremely challenging market environment," said John Thain, Merrill's chairman and chief executive officer in a written statement.

Merrill also took a pre-tax charge of $445 million due to staffing cuts. During the quarter, the company said it trimmed its ranks by 3,100, slightly more than it anticipated when it first announced the planned cuts in April. At the end of the quarter, Merrill's total employee count stood at 60,000.

The New York City-based firm also revealed that it would sell its 20% stake in the media outlet Bloomberg LP for $4.43 billion to Bloomberg Inc., confirming long-running speculation that it would sell assets in order to raise capital.

Merrill added it reached a tentative agreement over the sale of a controlling interest in the financial services administrator Financial Data Services for more than $3.5 billion.

Ongoing deterioration in the housing market, mounting troubles in the economy and pressure from regulators has prompted brokerages, Wall Street firms and banks of all sizes to raise additional capital.

But Merrill said it is holding onto its 49% stake in asset manager BlackRock (BLK, Fortune 500). Larry Fink, BlackRock's CEO, revealed earlier Thursday during his company's quarterly earnings release that the two firms would stay together. BlackRock reported a 23% increase in its earnings, beating expectations.

Thain, just 8 months into his tenure as CEO, told analysts during a conference call Thursday evening that the company was in a "comfortable spot" in terms of capital, following the two sales.

But Merrill's latest loss raised a red flag for one rating agency. Moody's downgraded Merrill's senior long-term debt rating Thursday evening following Merrill's report.

"Management's options to sell assets or raise more common equity to offset unexpected losses are now reduced given the difficult industry and capital markets environment," wrote Peter Nerby, a senior vice president at Moody's in a note.

Thain, the former NYSE Euronext CEO and Goldman Sachs alum, did not rule out the sale of its stake in BlackRock in the future should the company need to raise additional capital.

But he suggested, however, that the company would probably consider alternatives before making such a move.

"There are, in fact, other options on our balance sheet," said Thain.

Merrill is the latest financial firm to deliver second-quarter results this week.

Both JPMorgan Chase (JPM, Fortune 500), which reported earlier Thursday, and regional bank Wells Fargo (WFC, Fortune 500), saw their profits plunge during the quarter, but still managed to stay ahead of Wall Street's expectations. That news helped drive their shares, as well as the rest of the battered financial sector, higher the past two days.

Citigroup (C, Fortune 500) is expected to follow Merrill with its own ugly performance on Friday. Analysts expect the nation's largest bank by assets to lose more than $2.8 billion, or 61 cents per share.