PHH Corp. agreed to pay $45 million to settle allegations by 49 states, including New Jersey and Pennsylvania, that the Mount Laurel company improperly serviced mortgages between 2009 and 2012, several state attorneys general said Wednesday.

PHH, the nation's ninth-largest nonbank residential mortgage servicer, allegedly failed to accurately apply payments by certain borrowers in a timely manner, charged unauthorized fees for default-related services, and threatened foreclosure against borrowers who were engaged in loss mitigation, among other faulty tactics, according Pennsylvania's Attorney General Josh Shapiro.

The settlement includes $30.4 million in restitution for borrowers nationwide, including $1.2 million for 2,226 Pennsylvania residents and $746,925 to 1,980 borrowers in New Jersey.

Twelve attorneys general who led the investigation will share $5 million. PHH also must pay $8.8 million to state mortgage regulators as an administrative penalty, according to the settlement.

PHH issued a statement: "Our decision to resolve this legacy matter under the terms of the settlement agreement and consent orders is not an admission of liability or that we violated any applicable laws, regulations, or rules governing the conduct and operation of our servicing business during the relevant time frame. In fact, the servicing standards that we are required to adopt under the terms of the settlement are largely PHH's servicing standards today."