Bank of America Corp. said Monday that its second-quarter profit declined 32%, with results no longer fueled by big reserve releases.

The second-largest U.S. bank earned $6.2 billion, down from $9.2 billion a year earlier. Per-share earnings of 73 cents missed the 75 cents that analysts polled by FactSet had expected.

Revenue increased 6% from a year ago to $22.7 billion, slightly below analysts’ expectations.

Bank of America released $48 million in funds it had set aside to cover potential future losses. A year ago, the bank released $2.2 billion, lifting its profit at the time.

Last week, JPMorgan Chase & Co., Citigroup Inc., Wells Fargo & Co. and Morgan Stanley all reported double-digit drops in profit. Executives at the country’s largest banks said there is more uncertainty than usual about where the economy is headed. Some bank executives believe a recession is on the horizon, and that the Federal Reserve’s attempts to curb inflation with interest-rate increases could help spark the downturn.

Bank of America executives painted a bright picture of consumer finances, noting that customers have increased their spending while maintaining elevated deposit levels.

“The consumer’s in great shape, and the Fed’s got a lot of work to do,” Alastair Borthwick, Bank of America’s chief financial officer, said on a call with reporters Monday.

The Fed has been raising interest rates this year, including two big increases in the second quarter. Higher rates allow banks to charge more on loans, which can juice profits. The resulting market gyrations have also helped banks’ trading desks, which benefit from volatility.

Bank of America’s net interest income, including its lending profits, rose 22% from a year earlier to $12.4 billion, thanks largely to higher rates and stronger demand for loans.

Noninterest income, which includes fees, fell 9% from a year earlier to $10.2 billion. Lower investment-banking fees and changes to the bank’s overdraft policy dragged down fee income, Bank of America said. The bank said in January it would cut overdraft fees from $35 to $10.

Investment banking fees fell 46% from a year earlier to $1.2 billion. Investment banking revenue fell 54% at JPMorgan, 55% at Morgan Stanley and 46% at Citigroup in the second quarter.

Adjusted trading revenue increased 11% to about $4 billion.

Outstanding loans and leases grew 12% from a year earlier to just over $1 trillion. Loans in the bank’s commercial division rose 16%, while loans to consumers increased 7%. That is positive news for a bank that, like its peers, struggled to profit from lending for much of the pandemic because of rock-bottom interest rates and tepid loan demand.

Bank of America’s total expenses increased 1.5% to $15.3 billion. That amount includes about $425 million for costs related to regulatory matters. Last week, federal regulators fined Bank of America $225 million, saying the bank had mishandled the distribution of unemployment benefits at the height of the pandemic. The bank said last week that it worked with government clients “to identify and fight fraud throughout the pandemic.”

The bank set aside about $200 million for charges related to employees’ unauthorized use of personal phones. The bank hopes to settle in the coming weeks, Mr. Borthwick said. JPMorgan paid $200 million in a similar settlement last year. Morgan Stanley and Citigroup said last week they had set aside money for similar matters.

Bank of America shares rose 1.4% in early trading.

Write to Orla McCaffrey at orla.mccaffrey@wsj.com