When the U.S. Justice Department charged Standard & Poor’s with fraud earlier this month and demanded $5 billion in restitution, it was the culmination of the Obama administration’s four-year pursuit of financial chicanery masquerading as sacrosanct credit ratings.

Two dozen lawyers were assigned to a probe they called “Alchemy,” for the medieval pseudo-science that tried to turn lead into gold, as the department modeled a federal case on an analogy for failed mortgage-debt packages. They dug into 30 million documents, found cooperating witnesses and say they’ve got the evidence to win in court on an issue President Barack Obama since 2009 has been saying helped bring the U.S. economy to the brink of collapse.

“From the beginning of our effort to deal with the crisis, we had the ratings agencies high on the list,” former Representative Barney Frank, a Democrat and co-author of the 2010 Dodd-Frank financial regulation law, said in a telephone interview. “Our only frustration is that we couldn’t come up with better ways to deal with them, but we did everything we could think of in the legislation to restrict them.”

A review of legislative and regulatory documents and interviews with current and former administration officials shows that frustration with New York-based S&P, the nation’s largest ratings firm, Moody’s Corp. and Fitch Ratings has existed almost since Obama took office.

‘Brink of Collapse’

What started as an effort by Obama’s Treasury Department to right a system reeling from the worst financial breakdown in eight decades has now become a Justice Department lawsuit seeking $5 billion from S&P’s parent, McGraw-Hill Cos., after months of failed settlement talks.

The Justice Department, 16 states and the District of Columbia are suing the firm for fraud. Attorney General Eric Holder called its practices “egregious” and his deputy Tony West, the department’s third-ranked official, said the company played “a significant role in helping to bring our economy to the brink of collapse.”

The fight has so far cut more than $3.9 billion off McGraw- Hill’s market value, pushed the yields on its $400 million of bonds due November 2037 to the highest level since March 2011 and may threaten company’s viability.

S&P says it will “vigorously” defend itself from claims the company says are without merit. The Justice Department says it’s ready for court. It also doesn’t rule out renewed talks.

Because S&P is the only ratings company sued by the U.S. so far, some in the financial community say the case is retribution for the 2011 decision by S&P to downgrade U.S. debt.