J.P. Morgan Chase (JPM) said Friday its second-quarter earnings soared 31% after the massive “London Whale” trading loss in the year-ago period, beating Wall Street expectations.

Investment banking profit and credit quality came in stronger for J.P. Morgan, which also saw a benefit from setting aside less money to cover loan losses. During the quarter, the bank recorded a $1.5 billion release of its allowance for loan losses.

J.P. Morgan’s results showed some positive signs for consumers and businesses, with average loan balances in commercial banking rising 11% to $131.6 billion. The unit’s profit was $621 million, down 8% over last year but up 4% compared to the first quarter.

Consumer and community banking, which includes customers with checking accounts and credit cards, posted a $3.09 billion profit to reflect a 6% decrease year-over-year but a 19% gain sequentially.

U.S. consumers defaulted less, as delinquency rates on loans fell. That enabled the bank to set aside less money to handle future losses. Credit loss provision totaled $47 million, well below the first quarter’s $617 million.

J.P. Morgan’s profit checked in at $6.5 billion, surpassing the $4.96 billion profit logged a year earlier. On a per-share basis, earnings were $1.60 a share versus $1.21 a share. Analysts were looking for earnings of $1.44 a share.

The latest period included a gain of 15 cents related to the reduction in loan loss reserves, as well as other items.

Revenue climbed 13% to $26 billion, beating estimates for $24.84 billion. Noninterest expenses rose 6% to $15.87 billion.

Net interest margin narrowed to 2.2% from 2.37%.

The nation’s largest bank recorded a $355 million debit valuation adjustment gain, which accounts for the change in the value of its outstanding debt.

Mortgage banking profit was $1.1 billion, down 14% year-over-year on lower net revenue. The segment did see lower noninterest expense and lower provision for credit losses.

The investment banking segment saw its profit grow 19% to $2.84 billion, also reflecting a 9% increase over the prior quarter.

Shares were up 39 cents at $55.53 in early morning trading. As of Thursday’s close, the stock is up 62.6% over the last 12 months.

Follow Matthew Rocco on Twitter @MatthewRocco