The Financial Conduct Authority (FCA) fined Clydesdale, owned by National Australia Bank, £8.9m for the error, which dated back several years.
Clydesdale discovered in April 2009 it had miscalculated the repayments on 42,500 mortgages due to an error in how it had calculated repayments for customers with variable-rate mortgages.
The problem dated back to 2005 but only hit its customers when rates rose in 2008.
About 22,000 accounts were left with shortfalls – some of more than £18,000 – because they had not repaid enough. The total shortfall was £21.2m, or £970 each on average.
Clydesdale said it would compensate those who underpaid on their mortgages and would write to other affected customers.
The bank said the “vast majority” of the £42m cost of the error had been provided for by the end of June.
“I am very sorry that this wasn’t handled as it should have been. We should have made it clear at the time that this was entirely our fault and that some customers may be entitled to compensation,” said David Thorburn, Clydesdale chief executive.