JPMorgan Chase & Co. reported a 28% decline in its second-quarter profit Thursday.

The nation’s biggest bank set aside another $428 million to cover potential future loan losses, a signal it has grown more dour on the U.S. economic outlook.

That dragged down profit, which fell to $8.65 billion, or $2.76 per share, falling short of the $2.89-per-share forecast by analysts surveyed by FactSet.

JPMorgan shares fell 4% in morning trading. Broad markets also were down. Recession fears have weighed on the bank, causing its shares to underperform its peers and the broader market.

A year ago, the bank pulled $3 billion out of its loan-loss reserves due to the economy’s rapid recovery from the pandemic, pushing up profit to $11.95 billion, or $3.78 per share.

Revenue rose 1% to $30.72 billion. That missed the $31.81 billion analysts had expected.

Consumers increased spending on JPMorgan credit cards and kept paying their bills on time, even as the bank moved to prepare for potential future losses. Market volatility created a boon for trading operations, but dried up the advisory fees for initial public offerings and big deals. Increased interest rates meant its profitability on lending increased, but mortgage underwriting plunged.

The unusual atmosphere has created a divide in the economic views of bank executives, putting an extra spotlight on this season’s earnings reports. JPMorgan Chief Executive Jamie Dimon has said he saw an “economic hurricane” on the horizon, but he wasn’t sure how serious it would be.

“The truth of that is we’ve looked very carefully into the actual data and results and there is essentially no evidence of any weakness in the actual results,” Chief Financial Officer Jeremy Barnum

said about the economy on Thursday. “The questions are about the outlook.”

In the consumer bank, revenue fell 1% and profit dropped 45%, largely reflecting a release of funds set aside for soured loans in the second quarter of 2021. Spending on Chase credit cards rose 21% from a year ago and 15% from the first quarter, but fees collected on cards dropped. Bigger-ticket loans slumped, with mortgage originations down 45% and auto loan and lease origination down 44%.

In the corporate and investment bank, revenue fell 10% while profit dropped 26%

Fees from Wall Street trading rose 15% thanks to volatile markets and interest-rate swings. Investment banking fees dropped 54%, reflecting a slowdown in corporate dealmaking and stock sales from last year’s feverish pace.

Revenue increased 8% in the commercial bank and 5% in asset and wealth management.

Total loans increased 6% and were more profitable. The Federal Reserve raised rates by half a percentage point in May, and another 0.75 point in June. Another hike is expected this month. That allows banks to charge more interest on loans even as they are slow to increase the rate they pay on deposits.

The bank’s net interest margin, a measure of what it collects on loans minus what it pays for deposits, rose to 1.80% from 1.67% at the end of March.

Loans deemed uncollectible fell from a year ago to $657 million. With the $428 million reserve build, the bank’s total credit costs were $1.1 billion in the quarter.

The bank said it was temporarily suspending stock buybacks to retain more capital. Last month’s stress tests showed the biggest banks would need to hit higher capital requirements.

Write to David Benoit at david.benoit@wsj.com