(Bloomberg News) As markets convulsed in September 2008, Morgan Stanley Treasurer David Wong briefed the Federal Reserve on a "dark" scenario in which the U.S. firm would need at least $10 billion of emergency loans from the central bank.

It got 10 times darker by month's end. Morgan Stanley borrowed $107.3 billion, the most of any bank, according to data compiled by Bloomberg News using information released in response to Freedom of Information Act requests, related court orders and an act of Congress.

Morgan Stanley's borrowing -- more than twice the amount all banks got from the Fed in the market squeeze that followed the Sept. 11 terrorist attacks -- peaked after hedge funds pulled $128.1 billion from the firm in two weeks, documents released by the Financial Crisis Inquiry Commission show.

The first comprehensive examination of the Fed's emergency lending reveals how close the New York-based bank came to running out of cash because of a run on its prime brokerage, the unit that finances hedge funds' trades and holds their cash and securities. The Fed loans also show the degree to which Morgan Stanley and other banks depended on such brokerage accounts for funding, even though clients could close them on short notice.

"These were like hot-money deposits that could flee in an instant," said Tanya Azarchs, a former Standard & Poor's analyst who covered Morgan Stanley during the crisis and is now a consultant in Briarcliff Manor, New York. The firm "never thought that the hedge funds would get that spooked."

29,346 Pages

Morgan Stanley's Fed loans -- tallied in a Bloomberg News database assembled from government records of more than 21,000 transactions and 29,346 pages -- open a window on Wall Street's secretive, lucrative and risky dealings with hedge funds.

(View the Bloomberg interactive graphic to chart the Fed's financial bailout.)

The bank never told investors about the extent of its Fed borrowings, even as they rose to the most in the 97-year history of emergency lending by the U.S. central bank. Citigroup Inc., the New York-based lender whose balance sheet is more than twice the size of Morgan Stanley's, was the second-largest Fed borrower, with a balance of $99.5 billion in January 2009.

At the peak of Morgan Stanley's Fed borrowings, on Sept. 29, 2008, the firm reported that liquidity was "strong," without mentioning how dependent its cash stores had become on the government lifeline. Liquidity refers to the daily funds a bank needs to operate, including cash to cover withdrawals.