And the company's provision for credit losses was $948 million, down sharply from $1.5 billion a year earlier and beating the expectation for $1.46 billion as it released reserves because consumer credit improved. "There were some concerns that interest margins would start to deteriorate," said Octavio Marenzi, who runs management consultancy Opimas. That fear didn't bear out, he said. "There was some weakness in home lending, but cards and consumer banking more than made up for this, as well as a decline in fixed-income markets, but this was at least partially offset by gains in equities." J.P. Morgan's outlook for core loan growth was still 6 to 7 percent for 2018, the same guidance the bank gave in April. Some analysts had feared that lenders would report slowing loan growth amid rising rates and the administration's trade dispute.

The company's net interest margin, a widely-watched measure of profitability, rose 5 basis points from the previous quarter to 2.51 percentage points. That edged out the 2.50 percentage point estimate, showing that the bank is still capitalizing on the interest rate environment.

J. P. Morgan Chase topped analysts' expectations for third-quarter earnings and revenue Friday as better-than-expected retail banking results offset weakness in bond trading. The nation's largest bank by assets reported that revenue rose 5 percent to $27.8 billion, versus the $27.5 billion average estimate of analysts surveyed by Refinitiv. Earnings per share rose 33 percent to $2.34, beating expectations for $2.25. Shares of the New York-based bank fell 1 percent on Friday, giving up earlier gains at the open. Profit in the company's biggest division, consumer banking, surged 60 percent to $4.09 billion as the bank benefited from growing deposits and rising interest rates, resulting in more interest income. The retail bank attracted a record amount of fresh money, Chief Executive Officer Jamie Dimon said in the earnings press release.

The company posted $2.84 billion in fixed income revenue, a 10 percent decline that missed analysts' expectations for $2.96 billion. Equities trading came in at $1.6 billion, edging out the $1.43 billion estimate. Last month, the bank said that trading revenue was headed for a mid-single-digit decline.

J.P. Morgan is the first major lender to report earnings. The bank is closely watched by investors looking for clues into how the industry's Wall Street and Main Street businesses fared in the quarter. While the U.S. economic engine continued to roll in the quarter, conditions were arising that threaten that growth, Dimon noted.

"The U.S. and the global economy continue to show strength, despite increasing economic and geopolitical uncertainties, which at some point in the future may have negative effects on the economy," Dimon said in the release.

Bank stocks have been pummeled recently as surging U.S. interest rates stoke worries that the industry's profitability has peaked. While rising rates typically helps lenders early in the cycle, eventually competition for deposits forces banks to pay higher interest rates, shrinking margins. Sluggish loan growth could also hamper interest income, which is one of the main ways lenders make money.

The KBW Bank Index has dropped 5.8 percent since last week through yesterday, and shares of several banks including Wells Fargo and Goldman Sachs have fallen more than 20 percent from recent highs. J.P. Morgan has fared better at about 9 percent below its high-water mark.

Bank shares advanced Friday after other firms reporting earnings. Wells Fargo topped expectations amid the bank's revamp and Citigroup shares rose more than 2% after the company reported better-than-expected earnings.

Despite the uncertainty, J.P. Morgan is still making long-term bets on the U.S. economy. Last month, Dimon pledged $500 million for a new program called AdvancingCities to boost opportunities for people who have been left behind by economic growth. It also said it was opening 50 new branches in the Philadelphia area, part of a broader plan to use its corporate tax cut windfall to open 400 branches to deepen its retail reach.

WATCH: Bank earnings: What to watch