NEW YORK — Massive legal payouts didn't just cost JPMorgan Chase & Co. billions last year. They also cost the Wall Street giant its title as America's most profitable bank.

After weathering a barrage of legal and regulatory assaults in 2013, the New York bank said Tuesday that its annual profit slid 16% from the previous year to $17.9 billion.

JPMorgan's bottom line was eclipsed by the $21.9 billion earned last year by Wells Fargo & Co. despite a sharp industry-wide slowdown in mortgages. Wells Fargo, by far the nation's largest home lender, also reported its quarterly results Tuesday.

Weighing on JPMorgan's earnings in the fourth quarter was yet another whopping settlement — this time, $2.6 billion to settle federal investigations into its role in Bernard Madoff's Ponzi scheme.

"They would have had another record year," said Dick Bove, a bank analyst at Rafferty Capital Markets. "I don't think they're anywhere close to the end of the lawsuits that they're going to get hit with."

Improving fortunes for consumers nevertheless buoyed bottom lines for both JPMorgan and Wells Fargo, the first two major financial firms to report year-end financial results. As borrowers' ability to repay increased, the banks boosted their profits by cutting reserves for bad loans.

Wells Fargo said it earned $5.6 billion, or $1 a share, in the fourth quarter, up 10% from $5.1 billion, or 91 cents, a year earlier. The San Francisco bank, which wrote about a fifth of all U.S. home loans last year, saw growth in businesses outside its mortgage unit.

JPMorgan, the nation's largest bank by assets, said it earned $5.3 billion in the fourth quarter, or $1.30 a share, down 7% from $5.7 billion, or $1.39, in the same period a year earlier.

Net income from JPMorgan's investment banking unit slid 57%, dragged down in part by a $1.5-billion accounting loss related to derivatives and structured notes.

Analysts polled by Thomson Reuters had expected JPMorgan to earn $1.35 a share. Excluding the Madoff settlement and other one-time items, the bank would have earned $1.40 a share last quarter.

Both banks have been buffeted by downturns in mortgage originations as long-term interest rates rise, ending a boom in borrowers refinancing their home loans.

JPMorgan's mortgage originations fell 54% to $23.3 billion in the fourth quarter. Still, profit from its mortgage banking unit overall rose 34% to $562 million on cost-cutting and a decline in provisions for loan losses.

Wells Fargo wrote $50 billion of mortgages in the quarter, down 60% from $125 billion in the fourth quarter of 2012. Its pipeline of home loans fell 69% from $81 billion a year earlier to $25 billion, and profit on home lending fell from $3.1 billion to $1.6 billion.

The trend has affected Wells greatly because it collects payments on more home loans than any other bank. That gave it more chances to sell borrowers lower-rate mortgages, collecting origination fees and profits on sale of the loans. About a third of the bank's home loans during the fourth quarter were refinances compared with two-thirds a year earlier.

Improvements in such diverse categories as automobile lending, investment banking and credit cards helped offset Wells' mortgage-refinancing slump, which was "more severe than we had planned for," Chief Financial Officer Timothy Sloan said.

Still, bank executives believe that the housing recovery will continue, though with price increases moderating from their recent torrid pace. And that could bode well for growth in 2014.

"We've never had a sustained or significant economic recovery without a recovery in housing," Sloan said in an interview. "And over the last year and a half we've started to see that."

JPMorgan reported its own share of bright spots. Automobile loan originations, for example, grew 16% to $6.4 billion in the fourth quarter.

"It was not a great earnings report, but it wasn't terrible either," said Erik Oja, a banking analyst at S&P Capital IQ. "It was slightly better than expected."

Jamie Dimon, the bank's chairman and chief executive, said JPMorgan's underlying businesses showed strength, despite losing its distinction as the bank with the fattest bottom line.