JPMorgan Chase beat estimates for second-quarter profit on Friday, as its investment banking business benefited from a resurgence in dealmaking and strong capital market activity.

More companies are tapping capital markets to raise funds and striking takeover deals as they become confident in the U.S. economy's ability to avoid a major downturn, helping boost Wall Street banks' income from fees.

Investment banking fees grew 50%, compared with a low base, but were higher than the company's earlier prediction of 25% to 30%.

"While market valuations and credit spreads seem to reflect a rather benign economic outlook, we continue to be vigilant about potential tail risks," CEO Jamie Dimon said, adding that the risks included a changing geopolitical situation, which remains the most dangerous since World War II.

Inflation and interest rates may stay higher than market expectations due to threats like large fiscal deficits and restructuring of trade, Dimon said.

The largest U.S. bank set aside $3.1 billion in provisions for credit losses, 62% higher than the first quarter.

High rates continued to benefit lending, with net interest income (NII) - the difference between what it earns on loans and pays out on deposits - rising 4% to $22.9 billion.

Lending has remained healthy even as banks compete for deposits and face pressure to shell out more to depositors to store their money.

The largest U.S. bank's profit rose 25% to $18.15 billion, or $6.12 per share, for the three months ended June 30, compared with $14.47 billion, or $4.75 per share, a year earlier.

It had an accounting gain of about $8 billion from a share exchange deal with Visa. Excluding the Visa deal, net income was $13.1 billion compared.

The bank earned $4.26 per share, stripping out all one-time costs, compared with expectations of $4.19 per share, according to LSEG.

"We are encouraged by some of the economic trends that underpinned client activity in the second quarter and we remain cautiously optimistic as we head into the second half of the year," Jennifer Piepszak and Troy Rohrbaugh, co-CEOs of its commercial and investment bank, said in a post-earnings memo seen by Reuters.

TRADING BOOST

Trading was a bright spot in the quarter, fetching 10% higher revenue than last year. Revenue from fixed-income trading jumped 5% while equities saw a 21% jump.

The commercial and investment banking unit's revenue during the first half hit a record of $35.5 billion, the bank said.

Earlier this year, JPMorgan merged commercial, corporate and investment banking franchises under global banking.

"JPMorgan's results showed us two things: First, investment banking and equities trading did really well compared to last year," Opimas CEO Octavio Marenzi wrote in a note.

"Secondly, we see Main Street banking beginning to sputter," but the bank has navigated a challenging interest rate environment very well, he added.

The bank's shares dipped 0.6% in trading before the bell. They have gained 22% so far this year, but have underperformed rivals Bank of America, Citigroup and Wells Fargo .

Investors are also focused on succession planning at JPMorgan. The bank's board has identified several candidates to succeed Dimon, who is expected to step down in less than five years.

The contenders include Jennifer Piepszak and Troy Rohrbaugh, who jointly run the commercial and investment bank. The others are Marianne Lake, who leads consumer and community banking, and Mary Erdoes, the head of asset and wealth management.

JPMorgan's rival Wells Fargo missed analysts' estimates for interest income on Friday, due to higher deposit costs amid intense competition for customers' money.

(Reporting by Niket Nishant in Bengaluru and Nupur Anand in New York, editing by Lananh Nguyen and Anil D'Silva)