Combined profit at the six largest U.S. banks jumped last year to the highest level since 2006, even as the firms allocated more than $18 billion to deal with claims they broke laws or cheated investors.

A stock-market rally, cost cuts and a decline in bad loans boosted the group’s net income 21 percent to $74.1 billion, according to analysts’ estimates compiled by Bloomberg. That’s second only to 2006, when the firms reaped $84.6 billion at the peak of the U.S. housing bubble. The record would have been topped were it not for litigation and other legal expenses.