JP Morgan, the first Wall Street bank to report results in this closely watched earnings season, has revealed a surprise increase in revenue to $27.4bn even as legal bills and debt pinched first quarter earnings.

Smaller San Francisco-based rival Wells Fargo followed JP Morgan by reporting record net income of $4.2bn (£2.63bn) for the first quarter of 2012, compared with $3.8bn for the first quarter of 2011.

The New York bank reported a profit of $5.38bn for the first three months of 2012, down from $5.56bn a year earlier. The latest quarter included a loss tied to litigation expenses and changes in the value of the bank's debt.

The bank set aside $2.5bn toward its litigation costs during the first quarter mostly for mortgage-related lawsuits.

The bank increased its quarterly dividend to 30 cents a share from 25 cents a share and approved a $15bn stock buyback as mortgage revenues bounced back and trading almost doubled from the fourth quarter.

The first quarter earnings season is being closely watched as investors fear the US's fragile recovery may stall, as it did in the first quarter of 2010 and 2011. So far the signs have been good with better than expected results from aluminum giant Alcoa and strong results from Google.

JP Morgan's investment-banking arm turned in a profit of $1.68bn, down 29% from a year earlier although more than double what it booked in the fourth quarter.

The bank's retail-services business showed strong growth. The division, which handles consumer and small-business clients, reported a profit of $1.75bn, compared with a $399m loss a year earlier.

Mortgage fees and related revenue totalled $2bn, compared with a loss of $489m a year earlier. The bank said 200,000 mortgages were taken out in the first quarter.

"We are pleased that our results for the quarter reflected positive credit trends for our consumer real estate and credit card portoflios," chief executive Jamie Dimon said. But he warned that the housing crisis was not over. "We expect to see elevated levels of costs and losses associated with mortgage-related issues for a while longer," he said.

Earlier this month the bank awarded Dimon a $23m pay deal.