The student loan servicer that manages a deeply troubled program intended to forgive public servants’ education debts failed in its most basic tasks, depriving thousands of borrowers of a benefit they had earned, New York’s attorney general said in a federal lawsuit filed Thursday.

The servicer, the Pennsylvania Higher Education Assistance Agency, which does business under the name FedLoan, is the sole servicer for the federal government’s Public Service Loan Forgiveness Program. That program has become a notorious quagmire: Nearly 99 percent of those who applied to have their loans forgiven were denied, according to the latest data from the Education Department.

PHEAA’s failings directly caused many borrowers’ grim outcomes, Attorney General Letitia James said in her complaint, which was filed in Manhattan federal court. The servicer miscounted qualifying payments, failed to apply its policies consistently and left borrowers in limbo for as long as a year when they tried to get PHEAA to fix its mistakes.

“PHEAA’s abuses have not only denied these dedicated public servants the benefits they have earned, but have undermined the goals of the loan forgiveness program,” Ms. James said.