The Justice Department called S&P's claim "preposterous."
The world's largest ratings service said in documents filed in U.S. District Court in Santa Ana, Calif., the department's Feb. 4 lawsuit seeks to punish the McGraw Hill Financial Inc. division for exercising its First Amendment free-speech rights to rate the U.S. government's ability to pay back its debt.
"Plaintiff commenced this action in retaliation for Defendants' exercise of their free speech rights with respect to the creditworthiness of the United States of America," one of S&P's defense arguments alleges.
S&P calls the government's lawsuit "impermissibly selective, punitive and meritless."
The Justice Department argues federally insured banks and credit unions thought mortgage-linked debt packages rated highly by S&P were less risky than lower-rated securities.
But the department contends S&P was actually quietly assigning high ratings to the complex deals to satisfy bankers and other clients that wanted to buy them.
The $5 billion the government wants to collect is the amount the Justice Department alleges was lost by federally insured banks and credit unions that bought the mortgage-linked securities S&P rated.
S&P says the government hasn't explained how it got to the $5 billion figure, which The Wall Street Journal says equals about six years of the rating company's operating profit.
S&P downgraded the government's triple-A credit rating for the first time in history Aug. 5, 2011, during that summer's U.S. debt-ceiling crisis.
Besides the S&P action, the crisis caused the three major U.S. stock indexes and markets around the world to experience their most volatile week since the 2008 financial crisis, with the Dow Jones industrial average plunging 635 points, or 5.6 percent, in one day.
The Dow, which ended July 2011 at 12,143, fell 14 percent by Oct. 4, when the market started to recover, the Journal said.
S&P argued in its filings Tuesday the Justice Department singled it out because it was the only rating company to lower the U.S. rating. Moody's Investor Service and Fitch Ratings both have retained the government's triple-A rating and they're not being sued.
At a Feb. 5 news conference, acting Associate Attorney General Tony West, who has since been confirmed to the position, said there was "no connection" between the U.S. downgrade and the lawsuit.
He said the probe of S&P started in November 2009.
'Happy' fan videos make Pharrell cry [VIDEO]
Pregnant Mila Kunis wins 'Best Villain' at MTV Movie Awards