NEW YORK (CNNMoney.com) -- Wachovia reported a massive loss of nearly $24 billion Wednesday, in what was expected to be its last quarter as an independent company.

The struggling Charlotte, N.C.-based bank, which agreed to be acquired by Wells Fargo earlier this month, reported a net loss of $23.9 billion, or $11.18 a share, which included a whopping $18.8 billion impairment charge partly related to the planned merger.

Just a year ago, the company reported a profit of $1.62 billion, or 85 cents a share.

Despite the recent turmoil in financial markets, analysts were actually expecting the company to report a third-quarter profit of $547 million, or 2 cents a share.

Wachovia (WB, Fortune 500) shares fell 1.6% in early NYSE trading.

Wells Fargo execs, including CEO John Stumpf, said Wachovia's results were about as dreary as they expected after poring over the company's books and agreeing to buy the bank earlier this month.

"Wachovia's third-quarter results were very much in line with our expectations," Stumpf said in a statement.

Like many of its peers, Wachovia was hit hard this quarter by issues of credit and bad bets on the U.S. mortgage market, most notably its 2006 purchase of the California mortgage lender Golden West Financial Corp.

Over the last three months, the company said it set aside $4.8 billion for loan losses, as the economy showed increasing signs of weakness and the housing market continued to deteriorate in already hard-hit parts of the country such as California and Florida.

Wachovia added Wednesday that non-performing assets, or loans that are not collecting interest or principal payments, increased five-fold from a year earlier to just over 3% of all loans.

Still, much of the blame for Wednesday's results was the $18.8 billion impairment related, in part, to the tie-up with Wells Fargo.

Morgan Keegan analyst Robert Patten said the charge represented just how hard the two companies were working to clean up Wachovia's books before proceeding with the merger.

"You want to set up '09 to look as good as possible," he said.

Moot earnings

Assuming the company's anticipated merger with Wells Fargo (WFC, Fortune 500) comes off without a hitch, Wachovia's latest quarterly numbers will prove largely moot.

Still, the results offer a glimpse into just how badly the company was faring when investors seemed all but certain that Wachovia was destined to collapse.

Fears about Wachovia's ultimate demise first took hold in mid-September following the collapse of Lehman Brothers and shortly after Lehman rival Merrill Lynch was forced into the arms of Bank of America (BAC, Fortune 500).

Speculation continued to swirl about the 129-year-old bank in the days that followed, including rumors of a possible merger with with investment bank Morgan Stanley (MS, Fortune 500).

Even as Wachovia's consumer customers remained relatively calm about the bank's fate in the days that followed, Wednesday's results revealed that commercial depositors feared that the bank could be next. In just one quarter, the amount of commercial core deposits plunged by a colossal 24% from the previous quarter to $83.4 billion.

(Big customers flee)

Regulators finally interceded on Wachovia's behalf the last weekend in September, helping broker a $2.2 billion purchase of Wachovia's banking assets by Citigroup (C, Fortune 500).

Wachovia had a change of heart just days later, as it agreed to a sweetened offer from San Francisco-based Wells Fargo for all of Wachovia's operations.

After some legal wrangling, Citigroup eventually walked away, leaving Wells Fargo in control of Wachovia in a deal worth $11.7 billion.

Wachovia shareholders have yet to approve the deal, although they are widely expected to do so by year's end.

The combination of the two firms would transform Wells Fargo into a major player in the U.S. banking industry, with approximately $1.4 trillion in assets, a footprint in 39 states and the nation's second-biggest retail brokerage network.