Wells Fargo shares fell on Tuesday despite beating profit forecasts as investors punished lower net interest income than hoped and comments from management that expenses could remain on the higher end of projections into 2020.

The bank said its net income was $6.2 billion in the second quarter, up from $5.9 billion in the first quarter and $5.2 billion in the year-earlier period. However, net interest income — a main driver of bank profits — came in just shy of estimates at $12.1 billion. Net interest margin (NIM) fell 9 basis points from the prior quarter to 2.82% thanks to higher deposit costs and a "lower interest rate environment."

Here's how the company did compared with what Wall Street expected:

Earnings: $1.30 per share vs. $1.15 cents per share forecast by Refinitiv.

Revenue: $21.58 billion vs. $20.93 billion forecast by Refinitiv.

The bank's chief financial officer, John Shrewsberry, said on the company's earnings call later Tuesday that the company's expenses look to be on track to hit the higher end of a previously announced $52 billion to $53 billion range.

"Last quarter, we said we expected net interest income to decline 2% to 5% this year compared with 2018 and if the rate environment we are in today persists, we would expect to be near the low-end of the range," Shrewsberry said on the call.

On expenses, "our most recent forecast puts us at the higher end of our range for this year and, currently, our reforecasted 2020 is relatively flat with that number," he added, noting increased costs associated with risk and technological investments.

The company's stock fell 3% by the closing bell Tuesday, its worst day of trading since March.

The bank's loan balances at the end of June totaled $949.9 billion, up $1.6 billion from the first quarter as real estate, credit card and automobile lending all rose. Banks turn a profit by charging borrowers higher, longer-term interest rates compared with the lower, short-term interest rates they dole out to savers.