The Royal Bank of Canada will pay almost $22 million in compensation to clients who were charged excess fees on some mutual funds and investments products.

The payment is part of a no-contest settlement worked out by the Ontario Securities Commission and three units — RBC Dominion Securities, Royal Mutual Funds Inc. and asset manager RBC Phillips, Hager & North Investment Counsel Inc.

The OSC said in a release that the settlement comes after a compliance review in 2015 found the bank had overcharged some of its customers "excess fees," for their investments "that were not detected or corrected in a timely manner," the OSC said in a release.

The bank will reimburse affected customers $21,802,231 worth of investment fees it shouldn't have charged, and $975,000 to the OSC to pay for the investigation and to further the regulator's mandate to protect investors.

The rebate amount includes interest on the excess fees investors paid, the opportunity cost of which has been calculated at 5 per cent per year.

According to a settlement between the bank and the regulator, some of the bank's business units had been including investment products with embedded trailer fees inside fee-based accounts, where customers pay a fixed fee to have their investments managed.

In other cases, clients who qualified for lower-fee versions of some mutual funds due to the size of their account were not advised that they were eligible for lower-fee versions of the same investments.

The settlement document says fees were improperly charged to some clients as far back as 2005. Across all units, the bank believes 50,477 customer accounts were overcharged, the OSC says.

"OSC staff do not allege, and have found no evidence of dishonest conduct by ... RBC," the OSC said in a release.

The bank, for its part, says it is in the process of contacting all affected clients. "We are currently reaching out to all affected clients to ensure they are appropriately compensated. Affected clients will receive notification within the next few weeks," a spokesperson with the bank told CBC News.

Royal Bank isn't the only big Canadian lender to have admitted to overcharging on investment fees in recent years.

The regulator has reached no-contest settlements with eight other major financial firms including Bank of Montreal, TD, Scotiabank and CIBC in recent years for doing something similar.

All told, the OSC has recouped $342 million worth of fees that investors shouldn't have been charged as part of the regulator's latest investigation.