As rival J.P. Morgan Chase (JPM) struggles to explain a $4.4 billion trading blunder, Wells Fargo (WFC) narrowly beat the Street on Friday with a 17% jump in second-quarter earnings amid soaring mortgage banking profits.

Wells Fargo, the No. 4 U.S. bank by assets, said it earned $4.62 billion, or 82 cents a share, last quarter, compared with a profit of $3.95 billion, or 70 cents a share, a year earlier. Analysts had been calling for EPS of 81 cents.

On the other hand, revenue rose 4.4% to $21.29 billion, narrowly trailing the Street’s view of $21.36 billion.

“While the economic recovery remains uneven, we continued to meet our customers’ financial needs and benefited from signs of stabilization in the housing market,” CEO John Stumpf said in a statement.

San Francisco-based Wells Fargo, which leads all banks in home loans, was carried higher by an 81% year-over-year surge in mortgage banking income to $2.9 billion. Total loans rose to $775.2 billion, up $8.7 billion from the end of the first quarter.

Wells Fargo also reported a $195 million sequential decline in net charge-offs to $2.2 billion. Nonperforming assets dipped by $1.8 billion from the first quarter to $24.9 billion. Allowances for credit losses dropped to $18.6 billion from $19.1 billion in the first quarter.

Shares of Wells Fargo had a muted reaction to the earnings report, recently trading up 0.03% to $32.86. The shares have gained just over 2% so far this year and have slid 15.6% over the past 12 months.

The Wells Fargo report was largely overshadowed by J.P. Morgan, which said it took a $4.4 billion pre-tax trading loss tied to a failed hedging strategy. The largest U.S. bank by assets also posted net earnings per share of $1.21 on a 17% slump in revenue to $22.18 billion.

Follow Matt Egan on Twitter @MattMEgan5