King County in Washington state and Abu Dhabi Commercial Bank sued the rating agencies and investment bank Morgan Stanley, claiming that the agencies and the bank hid the risk of investing in a fund that purchased bonds backed by subprime mortgages. A federal court judge dismissed the lawsuits with prejudice Friday, meaning they cannot be filed again.

A representative for the McGraw-Hill Cos., which owns S&P, declined to comment Monday. A representative for Moody's Corp. did not respond to a request for comment.

Shares of both companies soared Monday on the elimination of the risk of the lawsuits, which dated back to the financial crisis.

Moody's shares jumped by $5.36, or 9.7 percent, to $60.48 in afternoon trading amid a broader market rally. The stock rose to $61.26 earlier in the session, a 52-week high.

McGraw Hill rose $1.85, or 3.6 percent, to $53.85. It's traded between $42.02 and $58.62 in the past 52 weeks.

Ratings agencies came under intense scrutiny following the 2008 financial crisis for giving top-notch ratings to investments backed by subprime mortgages. As defaults and losses mounted in the housing market, the value of bonds backed by the bad debt plummeted.