The complainants have accused BofA and a few of its officers of misleading them by making false claims about the financial status of the two financial institutes.
As per the settlement agreement, which is subject to court approval, BofA will pay $2.43bn and set up certain corporate governance policies.
Denying any wrongdoing, the bank said that it has entered into the settlement process to avoid "uncertainties, burden and expense of further prolonged litigation".
BofA chief executive officer Brian Moynihan said, "Resolving this litigation removes uncertainty and risk and is in the best interests of our shareholders.
"As we work to put these long-standing issues behind us, our primary focus is on the future and serving our customers and clients."
The United States District Court for the Southern District of New York judge Kevin Castel will review the proposed settlement agreement. The class action suit is pending in this court.
The compensation plan, including the incremental costs of the related settlement above previous accruals and other litigation-related items, will cost the bank nearly $1.6bn for the three months ended on 30 September 2012.
The bank has also announced that it will introduce certain corporate governance enhancements such as ‘say-on-pay’ vote option for shareholders, and annual disclosure of noncompliance with stock ownership guidelines.
BofA acquired Merill Lynch in 2009 for $19bn.