Ernst & Young agreed on Friday to pay $123 million to resolve a federal investigation into its role developing and marketing tax shelters that helped its clients avoid more than $2 billion in tax liabilities, the U.S. government said.

As part of the settlement, announced by the Manhattan U.S. Attorney’s Office, the accounting firm also entered into a nonprosecution agreement and admitted to the wrongful conduct of certain partners and employees.

The settlement amount reflects the gross fees Ernst & Young earned developing and marketing four tax shelter products from 1999 to 2004, according to the nonprosecution agreement.

The accord will resolve a longstanding federal investigation that has already netted other accounting firms accused of selling tax shelters that generated phony losses for well-off clients.

Ernst rival KPMG avoided indictment in 2005 over its sale of tax shelters, agreeing to a $456 million settlement.

In June 2012, accounting firm BDO USA agreed to a $50 million settlement over similar allegations.

In a statement, Ernst & Young said it disbanded in 2003 the group that put together the tax shelter services.

That year, Ernst agreed to pay a $15 million settlement to the Internal Revenue Service over the group’s promotion of the shelters. Ernst has been cooperating with the Justice Department’s investigation since 2004, the nonprosecution agreement said.

“Ernst & Young is pleased to put this matter from a decade ago behind us,” the firm said.

(Reporting by Nate Raymond, Reuters)