Revenue improved in many of the bank's major businesses, but the results were overshadowed by its bigger-than-expected legal costs. The bank had previously said that a settlement would cut into its earnings by $3.7 billion before taxes.

The extra litigation expenses came from setting aside money to cover future legal settlements tied to previously disclosed mortgage-related matters, Chief Financial Officer Bruce Thompson told reporters.

Still, the bank's setting aside more money does not mean a settlement is imminent, Thompson told analysts on a separate conference call.

The bank's shares fell 3.4 percent to $15.84 in morning trading on the New York Stock Exchange.

Rivals JPMorgan Chase & Co and Citigroup Inc had earned profits for the quarter.

Bank of America's quarterly loss, its first since the second quarter of 2011, underscores how much the bank is still suffering from its disastrous acquisition in 2008 of Countrywide Financial Corp at the height of the financial crisis. That deal was a key factor in the more than $50 billion of legal expenses the bank has logged since the financial crisis.

In March, Bank of America agreed to a $9.3 billion settlement to resolve claims that Countrywide and other Bank of America entities overstated the quality of the mortgages they sold to Fannie Mae and Freddie Mac between 2005 and 2007. [ID:nL1N0MN1XF] The bank had previously set aside funds to cover much of the settlement with the two agencies, but not all of it.

Indeed, the bank still has other home loan issues to resolve. In March, Bank of America said it was still subject to penalties and fines from the U.S. Department of Justice, state attorneys general, and other government authorities for mortgages and related bonds.

There was positive news for the bank in the results.

Income rose in its wealth management, trading, and retail banking businesses, and it wrote off fewer bad loans. It cut staff levels.

"Higher litigation costs clearly blurred the progress we made," said Thompson.

The bank reported a net loss for shareholders of $514 million, or 5 cents per share, for the quarter ended March 31. That comes after it earned a profit of $1.11 billion, or 10 cents a share, a year earlier.

Analysts, on average, had expected earnings of 5 cents per share, according to Thomson Reuters I/B/E/S.

LAGGING RIVALS

In 2013's first quarter, results were hit by $1.6 billion in charges related to disputes with bond insurers.

Revenue fell 3.8 percent to $22.66 billion, excluding accounting adjustments, but beat the average analyst estimate of $22.33 billion.

Bank of America's performance lagged rivals. Both Citigroup Inc and Wells Fargo & Co reported better-than-expected profit, while JPMorgan Chase & Co missed estimates as bond-trading revenue fell.

Bank of America's 2011 quarterly loss came after it took more than $20 billion of mortgage-linked charges. Taking into account the expense of paying dividends to preferred shareholders, the bank posted a net loss to common shareholders in the third quarter of 2012.

Goldman Sachs Group Inc and Morgan Stanley will report first-quarter results on Thursday.

The loss follows Bank of America's best year since before the financial crisis.

The bank's 2013 net income of $11.4 billion was the highest since 2007, but large legal bills and settlements left over from the financial crisis remain a drag on performance.

BofA made progress resolving many of its legal issues in the first quarter, although some proved to be costly.

In addition to the settlement with Fannie Mae and Freddie Mac, the bank received a New York judge's approval for its $8.5 billion settlement with investors in mortgage securities that went sour.

Litigation expenses of $6 billion compared with $2.2 billion in the first quarter of 2013. Non-interest expenses increased to $22.24 billion from $19.50 billion.

Costs in the bank's Legacy Assets and Servicing division, excluding litigation expenses, fell to $1.6 billion from $2.6 billion a year earlier and $1.8 billion in the third quarter.

The Charlotte-based bank has said that costs in the unit, which handles delinquent mortgage loans, would fall below $1.1 billion a quarter by the end of 2014 and will be about $500 million a quarter by the end of 2015.

BAD LOAN ALLOWANCES

Bank of America released $379 million from its allowances for bad loans, compared with $804 million in the same period a year earlier and $1.2 billion in the fourth quarter.

BofA's net charge-off ratio fell to 0.62 percent in the quarter from 1.14 percent in the same period a year earlier.

Revenue from fixed-income trading declined 1.7 percent to $2.95 billion as many clients took to the sidelines in the quarter, awaiting clarity from the Federal Reserve on its interest rate intentions.

Results in the year-ago quarter were hurt by a settlement with a bond insurance company. Adjusting for that settlement, bond trading revenue fell 15 percent in the first quarter of 2014, the company said.

Still, the bank performed better than Citigroup, whose revenue from the business fell 18 percent. JPMorgan Chase's bond trading revenue dropped 21 percent, including an accounting adjustment that Bank of America and Citigroup strip out.

Bank of America's net interest margin, excluding market-related adjustments, was 2.36 percent, compared with 2.30 percent in the first quarter of 2013.

During the quarter, the bank received the Federal Reserve's blessing to increase its quarterly dividend to 5 cents per share from 1 cent and repurchase $4 billion in common shares.

(Reporting by Peter Rudegeair in New York and Tanya Agrawal in Bangalore; Editing by Ted Kerr, Dan Wilchins and Bernadette Baum)

By Peter Rudegeair and Tanya Agrawal