NEW YORK — Bank of America made $2 billion in the last three months of last year, reversing a loss from a year earlier. It offset legal expenses over mortgages and losses in its investment banking business by selling debt and its stake in a Chinese bank.

The bank said Thursday that it made 15 cents per share in the fourth quarter. That fell short of the 22 cents expected by analysts surveyed by FactSet, a provider of financial data, but was in line with other estimates.

For the year, the bank made $1.4 billion. It lost $2.2 billion in 2010.

Bank of America has been raising cash by selling pieces of itself that don’t fit into its basic banking model. The strategy was also a way to prepare for a Federal Reserve stress test, which is under way, and meet international regulatory standards.

“We enter 2012 stronger and more efficient after two years of simplifying and streamlining our company,” CEO Brian Moynihan said.

Bank of America’s results are considered a gauge of the health of the American consumer. The bank serves about half of American households. The results showed that housing continues to remain a concern in the economy.

Bank of America’s real estate business lost $1.5 billion after a 74 percent decline in new home loans. The bank lost some market share and closed a division that helped third-party home lenders.

But Americans seemed to be getting their financial houses in order by paying off more debt on time.

Bank of America, one of the largest credit card issuers, said customers who paid bills a month late declined for the 11th consecutive quarter. New credit card accounts also grew 53 percent, and the division posted a profit of $1 billion.

Already dealing with an image problem after the 2008 financial crisis, Bank of America caused an uproar last fall when it announced a $5 monthly fee for its debit cards. The bank quickly backed off.

Banks have been raising all types of customer fees. They say they need to make up lost revenue because a federal law that took effect last year caps what banks can charge stores for purchases paid for with the swipe of a debit card.

The $2 billion net income for the fourth quarter compared with a $1.2 billion loss in the same quarter a year ago. Revenue was $25.1 billion, up 11 percent and higher than the $23.7 billion estimated by FactSet.

The bank made $2.9 billion by selling its stake in China Construction Bank and $2.4 billion more selling debt and exchanging its higher-cost preferred stock for common stock.

Bank of America stock was clobbered for two years and lost more than 60 percent of its value. But the market seems to like what Moynihan is doing. The stock has soared 23 percent in 2012. It was up 6.6 percent in pre-market trading to $7.26.

Bank of America’s investment banking business reported a loss of $433 million due to lower investment banking fees and lower sales and trading driven by the rocky stock and bond markets in the last three months of the year.