For several hours Friday, thousands of St. Paul School District employees were in danger of having a very un-Happy New Year.

A glitch in the district’s payroll system was to blame, and employees whose pay is deposited directly to their bank accounts were fuming, leading to dozens of nasty comments on the Facebook page of the local teachers union.

Instead of their expected pay Friday, employees with direct deposit got only this depressing reassurance from the school district early in the day: Their pay would be delayed, and district officials had no idea how long it would take to correct the problem.

By Friday afternoon, however, all was well, or at least, a whole lot better.

At 4 p.m., the district posted on its website that 95 percent of the 7,361 direct deposits planned for payroll had been deposited. By 5 p.m., all but 95 district employees had been paid.

The problem appears to have been traced to something called an electronic automatic clearinghouse (ACH) process. An error in that process led to the delay, officials said.

“SPPS today worked with US Bank to resolve this issue by sending money via wire transfers so that further delay was avoided,” a district statement read. “We are grateful to US Bank for their speedy response to this issue. If you were one of the affected employees, please check your account to ensure your payment was received.”

Officials asked employees to note if there were “wire transfer fees” or overdraft fees charged to their account as a result of the glitch. As of Friday afternoon, St. Paul public schools’ payroll department was creating a way for employees to be reimbursed for those fees, officials said.

Earlier, some employees took to the Facebook page of the teachers union to express their displeasure.

“Wow, this is very unprofessional,” wrote one teacher.

Said another: “Payroll has always been awful. I can’t even count how many times my check has been messed up. Plus, I never can get anyone on the phone and [they] don’t return messages.”

The St. Paul Federation of Teachers sent an e-mail to Laurin Cathey, executive director of human resources and the head of district payroll, saying:

“This is a serious issue that should have been anticipated and prevented by Payroll. Will you be offering live checks to employees who come in to [district headquarters] today? It is not acceptable to leave employees without pay over the weekend. Due to the holiday, that would present serious hardships.”

The teachers union said it would investigate the cause of the error and “if warranted, we will file a grievance requesting compensation for any employee who suffers overdrafts, fees or other consequences as a result.”

St. Paul schools officials were hoping that would not be necessary.

“Again, we apologize for today’s problems and thank you for your patience,” officials said. “We wish you … a peaceful, worry-free weekend.”