Shares of S&P parent McGraw-Hill fell sharply on news of the looming suit.

Standard & Poor's revealed Monday that it is set to face a lawsuit from the U.S. government over its inaccurate ratings of mortgage-related investments in the run-up to the financial crisis.

The ratings agency said in a statement that the Department of Justice "has informed the company that it intends to file a civil lawsuit against S&P focusing on its ratings in 2007 of certain U.S. collateralized debt obligations," investments based on pools of mortgages.

S&P called the potential lawsuit "entirely without factual or legal merit." The firm said that it "deeply regrets" the fact that its ratings "failed to fully anticipate the rapidly deteriorating conditions in the U.S. mortgage market," but that it relied on the same data as U.S. government officials and other analysts who failed to predict the housing bust.

Analysts have long pointed to ratings agencies as key culprits in the financial crisis.

Wall Street firms and other investors rely on the agencies to analyze risk and give debt a "grade" that reflects the borrower's ability to pay the underlying loans. The safest investments are rated "AAA."

Some investors, including pension funds and insurance companies, operate under guidelines that require them to hold a certain percentage of highly rated securities in their portfolios.

In the years preceding the meltdown in 2008, large numbers of mortgage-backed securities received AAA ratings, only to fail as the housing market collapsed. Critics say that because the major ratings agencies are paid by banks and other issuers of securities rather than investors, they succumbed to a conflict of interest in giving their seals of approval to dubious investments.

"Credit rating agencies allowed Wall Street to impact their analysis, their independence and their reputation for reliability," U.S. Senator Carl Levin said in a 2010 hearing. "And they did it for the money."

A 2011 Senate report on the financial crisis said the agencies "weakened their standards as each competed to provide the most favorable rating to win business and greater market share."