Timothy J. Sloan, the embattled chief executive of Wells Fargo, abruptly stepped down on Thursday as one of the country’s largest banks struggles to recover from a series of self-inflicted scandals.

Mr. Sloan took over the top job in 2016 with a mandate to clean up the bank after his predecessor was forced to resign. Once regarded as among the nation’s best-run financial institutions, Wells Fargo admitted in 2016 that it had for years opened what may have been millions of fictitious accounts in customers’ names, improperly charged them fees and sold them unwanted products.

But Mr. Sloan, who has been at the company for 31 years, could do little to stem renewed criticism about the bank’s culture and sales practices. In fact, he became a lightning rod for criticism, including from members of Congress who called for his resignation.

“I could not keep myself in a position where I was becoming a distraction,” he said on a conference call with analysts.