A slowdown in mortgage lending and a decline in the value of equity investments helped send Wells Fargo & Co.’s second-quarter profit down 48%.

The San Francisco-based bank said it earned $3.12 billion in the quarter, down from $6.04 billion a year ago. Per-share earnings totaled 74 cents, below the 80 cents expected from analysts polled by FactSet.

The bank posted revenue of $17.03 billion, down 16% from $20.27 billion a year ago. Analysts expected $17.48 billion.

The market downturn prompted Wells Fargo to take a $576 million charge to account for a decline in the value of its venture-capital and private-equity investments. Rising interest rates, meanwhile, hit the bank’s mortgage business, drying up demand for refinancings. Wells Fargo, one of the country’s largest mortgage lenders, said originations fell 36% in the second quarter.

“It’ll be a challenging market in the mortgage business for the next couple of quarters as things start to stabilize and we see where the path of rates will go,” Mike Santomassimo, Wells Fargo’s chief financial officer, said on a call with reporters Friday morning.

Investors are paying attention to big-bank earnings for signs about whether a recession is on the horizon. JPMorgan Chase & Co. and Morgan Stanley reported lower second-quarter profits Thursday, sending bank stocks down across the board. Bank stocks tend to rise and fall with expectations for the broader economy, since their businesses closely track the financial health of consumers and businesses.

Wells Fargo shares rose $2.39, or 6.2%, Friday to $41.13, their highest closing price since early June. The bank’s shares are down 14% on the year, compared with a 19% drop in the S&P 500.

The bank said it set aside $235 million in new funds to cover potential losses because of loan growth it experienced during the quarter. A year ago, the bank released $1.64 billion in funds it had set aside for potential loan losses.

Outstanding loans rose 11% from a year ago and 4% from the previous quarter. Wells Fargo’s commercial segment powered the growth, recording a 15% increase from a year ago. Loans in the bank’s consumer division rose 5%.

The bank said its net interest income, a measure of lending profit, rose 16% to $10.2 billion, thanks to higher rates and loan balances. Wells Fargo expects net interest income to increase about 20% in 2022 compared with 2021.

The Federal Reserve has raised rates three times so far this year, including twice in the second quarter. Higher interest rates typically benefit banks, but investors are concerned the central bank’s rapid rate hikes could tip the economy into a recession.

Auto loan originations decreased 35%. Revenue from credit cards and personal loans increased 7% each from a year ago.

The bank’s noninterest income fell 40% to $6.83 billion. Expenses totaled $12.88 billion, down 3% from the same period last year.

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