Wells Fargo plans to cut as many as 26,500 jobs over three years as the troubled bank grapples with the rise of online banking and soaring legal bills.

CEO Tim Sloan said on Thursday that Wells Fargo (WFC) plans to cut 5% to 10% of its 265,000-person workforce. He cited "changing customer preferences," including the wide adoption of digital banking.

Wells Fargo said that the reduction in its workforce would reflect layoffs as well as attrition.

"Wells Fargo takes very seriously any change that involves its team members, and as always, we will be thoughtful and transparent, and treat team members with respect," Sloan said in a statement.

The bank has been under pressure to cut costs following a wave of scandals over the past two years. The legal trouble has cut into Wells Fargo's once-vaunted profitability. Regulators have handed down hefty fines, and the scrutiny has driven up compliance and marketing costs.

Wells Fargo reported declines last quarter in profit, loans, deposits and revenue. Expenses continued to rise, however.

The bank's branch network no longer looks like the reliable moneymaker it once was. The fake-accounts scandal, which was caused by wildly unrealistic sales goals, forced the bank to revamp its incentive structure.

Now Wells Fargo is joining other big banks, which have shut down thousands of branches in recent years. In January, the company said it would shut down another 800 branches by 2020.

Wells Fargo also announced a deal in June to sell all of its branches in Indiana, Michigan and Ohio. The sale means that America's third-largest bank will no longer have a retail presence in a major part of the Midwest.