(Bloomberg) -- Bank of America Corp., shaking off some of the drag caused by faulty mortgages, swung to a second- quarter profit as losses in real estate narrowed and the company set aside less for bad loans.

Net income was $2.46 billion, or 19 cents a share, compared with the year-earlier record loss of $8.83 billion, or 90 cents a share, the Charlotte, North Carolina-based company said today in a statement. Results beat the 15-cent average estimate of 25 analysts surveyed by Bloomberg.

The biggest U.S. banks have struggled to expand revenue amid a weak economy, putting pressure on Chief Executive Officer Brian T. Moynihan to control expenses. In March, he promised “demonstrable progress” every quarter, with more than 30,000 jobs targeted for elimination at retail and support divisions, and the CEO today announced $3 billion more of cuts at the investment bank, trading and wealth management.

“We’re counting on expense efficiencies to be the primary driver of earnings,” said Marty Mosby, an analyst at Guggenheim Securities LLC, which manages more than $100 billion, including Bank of America stock. “They’re bringing down their balance sheet and increasing their capital ratios, which you hope helps them eventually pay a modest dividend.”

Bank of America surged 42% this year in New York trading, the best performance in the Dow Jones Industrial Average. Still, the lender’s shares lost almost half their value since Moynihan took over in 2010, compared with a 23% gain for the Dow Jones benchmark. The shares rose 1.9% to $8.07 in early New York trading.

Cost Containment

“Brian has been doing exactly the things in terms of correcting problems for the past, exactly what I would be doing,” said Warren Buffett, whose Berkshire Hathaway Inc. invested $5 billion in the bank, in a July 13 interview with Bloomberg Television’s Betty Liu. “He’s done a terrific job. He’s gotten rid of one thing after another that was a problem. And he’s getting it back to basic banking.”

Bank of America cited higher mortgage banking income, with first-lien originations rising 18% from the first quarter, and the company put aside less money to cover refunds for investors on soured loans. The bank’s $1.77 billion provision for credit losses shrank from $3.26 billion a year earlier and was the smallest since 2007, according to the bank. The real estate unit’s loss narrowed to $768 million from $14.5 billion a year earlier.

Expenses Decline

Noninterest expense dropped to $17.0 billion from $19.1 billion in the first quarter and $22.9 billion in the second quarter of 2011, with the staff shrinking by 3,228 to 275,460 full-time workers, according to the bank.

Low interest rates and lending eroded some of the gains, according to the company, with sales and trading revenue at the markets unit slipping to $3.2 billion in the second quarter of 2012, from $3.8 billion in the first quarter and $3.7 billion in the second quarter of 2011. Excluding an accounting adjustment for changes in debt values, sales and trading revenue was $3.3 billion, compared to $5.2 billion in the first quarter of 2012 and $3.6 billion 2011’s second quarter.

The first phase of Moynihan’s efficiency plan, called Project New BAC, will trim $5 billion in costs from deposit, credit-card and mortgage operations. That brings Moynihan’s target for cost-cutting to $8 billion, and he said today the savings should be in place by 2015. The CEO has said the second phase will result in fewer job reductions than the first because investment banking and trading units have smaller staffs.

Moynihan divested more than $50 billion in assets to make the firm more focused and boost capital levels. The bank is in talks to sell its non-U.S. wealth-management operations to Julius Baer Group Ltd., the Zurich-based firm said last month.

Takeover Binge

Under Moynihan’s predecessor Kenneth D. Lewis, the company ballooned to become the biggest U.S. bank through more than $130 billion in takeovers. One of them was Countrywide Financial Corp., the mortgage company that was careening toward bankruptcy in 2008. Bank of America has since been stung by more than $40 billion in costs tied to faulty home loans and foreclosures, which fueled the firm’s record loss in the year-earlier period.

The bank agreed to pay Syncora Holdings Ltd. $375 million to resolve a dispute over soured mortgages, the Bermuda-based insurer said yesterday.

Bank of America ranked as the biggest U.S. home lender after buying Countrywide with almost a quarter of the market. It’s now No. 4 with a 4.2% share as of March 31, according to trade journal Inside Mortgage Finance, leaving Wells Fargo & Co. and JPMorgan Chase & Co. to benefit from a refinancing boom amid record-low interest rates. 

Wells Fargo

Wells Fargo, the biggest U.S. home lender with about 34% of the market, posted a 17% profit increase to $4.62 billion as earnings from mortgage banking surged almost 80% to $2.89 billion at the San Francisco-based firm.

JPMorgan, the biggest U.S lender by assets, said second- quarter profit fell 9% to $4.96 billion after a trading loss in its chief investment office. Mortgage fees and related revenue at the New York-based firm doubled from a year earlier.

Citigroup Inc., the No. 3 lender, posted a 12% profit decline to $2.95 billion amid drops in revenue from trading stocks and bonds and the impact of a strengthening dollar on overseas earnings.