Wells Fargo wfc has been ordered to pay $185 million to settle charges that employees had fraudulently signed customers up for deposit and credit card accounts to hit sales targets and receive bonuses, according to regulators.

The Office of the Comptroller of the Currency, the Consumer Financial Protection Bureau (CFPB), and the Los Angeles City Attorney each announced settlements with Wells Fargo on Thursday. Los Angeles first filed a lawsuit against the bank in May 2015.

“Because of the severity of these violations, Wells Fargo is paying the largest penalty the CFPB has ever imposed,” bureau director Richard Cordray said in a statement.

Investigators found that Wells Fargo employees opened deposit and credit card accounts without consent from consumers. Employees would then transfer funds from the consumers’ legitimate accounts temporarily into the new, unauthorized accounts.

Wells Fargo employees even went as far as secretly creating PINs, false email, and phone addresses for unauthorized deposit accounts, according to the CFPB.

This widespread practice gave the employees credit for opening the new accounts, allowing them to earn additional compensation and to meet the bank’s sales goals,” the CFPB’s press release read. “Consumers, in turn, were sometimes harmed because the bank charged them for insufficient funds or overdraft fees because the money was not in their original accounts.”

The unauthorized credit cards also came with accompanying annual fees and other charges.

The CFPB says that by the bank’s own estimates, Wells Fargo employees applied for roughly 565,000 credit cards and 1.5 million deposit accounts that may have not been authorized by consumers.

The Office of the Comptroller of the Currency decided that the bank had failed to develop a effective oversight system to detect and prevent such sales practices and ordered the company to pay a $35 million civil penalty. The City and County of Los Angeles will be paid $50 million, while the CFPB is to be paid $100 million.

Additionally, Wells Fargo will have to refund affected customers—the CFPB expects those charges to total at least $2.5 million—and hire an independent consultant to conduct a thorough review of the bank’s procedures. The bank has already refunded $2.6 million, with each refund averaging $25.

 

“Wells Fargo reached these agreements consistent with our commitment to customers and in the interest of putting this matter behind us,” the bank wrote in a press release. “Wells Fargo is committed to putting our customers’ interests first 100% of the time, and we regret and take responsibility for any instances where customers may have received a product that they did not request.”

Wells Fargo also confirmed to Fortune, as first reported by CNNMoney, that it had fired roughly 5,300 people in connection with the findings. Those terminations took place between 2011 and March 2016.

“Today’s action should serve notice to the entire industry that financial incentive programs, if not monitored carefully, carry serious risks that can have serious legal consequences,” Cordray said.

It’s not Wells Fargo’s first run in with the CFPB. In late August, the CFPB took action against the banking giant for illegal private student loan services, saying the company had increased costs and unfairly penalized some student loan borrowers. The bureau demanded about $3.6 million from Wells Fargo, in addition to some $410,000 in relief to borrowers.

Shares of Wells Fargo remained relatively flat Thursday.