Image source: The Motley Fool.

Not many banks can match Wells Fargo (WFC 0.89%) when it comes to profitability, but even it isn't immune from the increasingly inhospitable environment for banks.

The nation's third-biggest bank by assets said on Friday that its profit in the second quarter fell by $161 million, or 3%, compared to the year-ago period. It marked the fifth time in six quarters that Wells Fargo's net income dropped on a year-over-year basis, highlighting the headwinds that banks face from ultralow interest rates.

It earned $5.6 billion, or $1.01 per share, in the three months ended June 30. That came in right around the consensus estimate. In the wake of the results, Wells Fargo's stock is down by nearly 3% halfway through the trading day.

Data source: Wells Fargo. Chart by author.

There was, nevertheless, a lot to like in Wells Fargo's performance. First and foremost, as was the case when JPMorgan Chase reported earnings yesterday, Wells Fargo grew its loan portfolio at a rapid clip. Compared to the same period last year, its average loans increased by $80 billion, or 9%.

Its larger loan (and securities) portfolio more than offset the drag from lower interest rates, which caused Wells Fargo's net interest margin to decline from 2.9% in the first quarter to 2.86% in the second quarter. The offsetting impact is clear when you consider that the bank's net interest income rose by 4% compared to the second quarter of 2015.

It's also worth pointing out that, even Wells Fargo's diminished bottom line still translates into industry-leading profitability. Its return on average assets last quarter was 1.2%, or well in excess of the traditional 1% benchmark that other banks are struggling to eclipse. And it earned an 11.7% return on equity, which is better than the roughly 10% that it needs to create value for shareholders.

"Wells Fargo's second quarter results demonstrated our ability to generate consistent performance during periods of economic, capital markets and interest rate uncertainty," said chairman and CEO John Stumpf in prepared remarks. "Compared with a year ago, we had solid growth in loans, deposits and customers, which are our fundamental drivers of long-term value. We also improved our efficiency ratio while continuing to reinvest in the franchise."

More than offsetting these benefits, which boosted Wells Fargo's net revenue by 4% relative to last year, were higher loan-loss provisions and expenses. Provisions more than tripled, to $1.1 billion for the quarter, thanks principally to its oil and gas portfolio, which is buckling under the pressure of low energy prices.

"Oil and gas portfolio performance during the quarter was generally consistent with our expectations," said chief risk officer Mike Loughlin. "Results in the oil and gas portfolio remained under pressure with higher credit losses and nonaccrual loans, while our allowance coverage ratio for the portfolio remained stable at 9.2 percent at quarter-end."

Wells Fargo's operating expenses, meanwhile, grew by $400 million compared to last year's second quarter; importantly, however, its efficiency ratio fell, as revenue rose faster than expenses (the efficiency ratio measures the percentage of net revenue that's consumed by noninterest expenses). Wells Fargo ended the quarter with a 58.1% efficiency ratio, which is at the high-end of its target range (lower is better), but still laudable given the industry's headwinds.

There's no getting around the fact that banks are operating in a challenging environment right now. Low interest rates combined with economic uncertainty related to China's lagging economic growth and the turmoil surrounding the U.K.'s Brexit vote are all weighing on banks' top and bottom lines. And higher capital and liquidity requirements passed in the wake of the crisis are catalyzing these negative trends.

Through all of this, however, the best-run banks will prevail, and likely even gain market share. It's for this reason that I remain bullish on Wells Fargo's stock. It's performed well for decades, and with a 3.2% dividend yield, it's no less attractive today.