This article was reported by Jenny Anderson, Eric Dash and Andrew Ross Sorkin and was written by Mr. Sorkin.

In one of the most dramatic days in Wall Street’s history, Merrill Lynch agreed to sell itself on Sunday to Bank of America for roughly $50 billion to avert a deepening financial crisis, while another prominent securities firm, Lehman Brothers, filed for bankruptcy protection and hurtled toward liquidation after it failed to find a buyer.

The humbling moves, which reshape the landscape of American finance, mark the latest chapter in a tumultuous year in which once-proud financial institutions have been brought to their knees as a result of hundreds of billions of dollars in losses because of bad mortgage finance and real estate investments.

But even as the fates of Lehman and Merrill hung in the balance, another crisis loomed as the insurance giant American International Group appeared to teeter. Staggered by losses stemming from the credit crisis, A.I.G. sought a $40 billion lifeline from the Federal Reserve, without which the company may have only days to survive.