California Attorney General Kamala Harris (right), accompanied by Attorney General Eric Holder, speaks during a news conference Tuesday at the Justice Department in Washington. The U.S. government accused Standard & Poor's of inflating ratings on mortgage investments to boost its bottom line, taking aim at a key player in the run-up to the financial crisis. (ASSOCIATED PRESS / Jacquelyn Martin)

The credit rating agency gave high marks to mortgage-backed securities because it wanted to earn more business from the banks that issued the investments, the Justice Department alleges in civil charges filed in federal court in Los Angeles.

The government is demanding that S&P to pay at least $5 billion in penalties.

The case is the government’s first major action against one of the credit rating agencies that stamped their approval on Wall Street’s soon-to-implode mortgage bundles. It marks a milestone for the Justice Department, which has long been criticized for failing to act aggressively against the companies that contributed to the crisis.

S&P, a unit of New York-based McGraw-Hill Cos., called the lawsuit “meritless.”

“Hindsight is no basis to take legal action against the good-faith opinions of professionals,” the company said in a statement. “Claims that we deliberately kept ratings high when we knew they should be lower are simply not true.”

According to the lawsuit, S&P knew that home prices were falling and that borrowers were having trouble repaying loans. Yet these realities weren’t reflected in the safe ratings S&P gave to complex real-estate investments known as mortgage-backed securities and collateralized debt obligations.

At least one S&P executive who had raised concerns about the company’s proposed methods for rating investments was ignored.

S&P executives expressed concern that lowering the ratings on some investments would anger the clients selling these investments and drive new business to S&P’s rivals, the government claims.

“Put simply, this alleged conduct is egregious — and it goes to the very heart of the recent financial crisis,” Attorney General Eric Holder said at a news conference Tuesday.

Holder called the case “an important step forward in our ongoing efforts to investigate and punish the conduct that is believed to have contributed to the worst economic crisis in recent history.”

The $5 billion in penalties the government is demanding would amount to several times the annual revenue of McGraw-Hill’s Standard & Poor’s Ratings division. The ratings business generated $1.77 billion in revenue in 2011. McGraw-Hill’s total revenue was $6.25 billion.

Joining the Justice Department in the announcement were attorneys general from California, Connecticut, Delaware, the District of Columbia, Illinois, Iowa and Mississippi, who have filed or will file separate, similar civil fraud lawsuits against S&P.

On Tuesday, California’s attorney general filed a lawsuit in San Francisco Superior Court claiming that S&P’s inflated ratings on risky mortgage bonds cost the state’s public pension funds and other investors billions of dollars.

More states are expected to sue, the Justice Department said.

Rating agencies are widely blamed for contributing to the financial crisis that caused the deepest recession since the Great Depression. They gave high ratings to pools of mortgages and other debt assembled by big banks and hedge funds. Their ratings gave even risk-averse investors the confidence to buy them.

Some investors, including pension funds, can buy only investments with high ratings. In effect, rating agencies like S&P greased the assembly line that allowed banks to package and sell risky mortgages that generated huge profits.

When the housing market collapsed in 2007, the agencies acknowledged that mortgages issued during the bubble were far less safe than the ratings had indicated. They lowered the ratings on nearly $2 trillion worth, spreading panic that spiraled into a crisis.

In its statement Tuesday, S&P said its ratings “reflected our current best judgments” and noted that other rating agencies gave the same high ratings. It said the government also failed to predict the subprime mortgage crisis.

But the government says the company delayed updating its ratings models, rushed through the ratings process and kept giving high ratings even after it knew the subprime market was flailing.

The complaint includes a trove of embarrassing emails and other evidence that S&P analysts saw the market’s problems early:

— In 2007, an analyst who was reviewing mortgage bundles forwarded a video of himself singing and dancing to a song written to the tune of “Burning Down the House”: “Going — all the way down, with/Subprime mortgages.” The video showed colleagues laughing at his performance.

— A PowerPoint presentation that year said being “business friendly” was a core component of S&P’s ratings model.”

— In a 2004 document, executives said they would poll investors as part of the process for choosing a rating. One executive asked, “Does this mean we are to review our proposed criteria changes with investors, issuers and investment bankers? ... (W)e NEVER poll them as to content or acceptability!” The executive’s concerns were ignored, the government said.

— Also that year, an analyst complained that S&P had lost a deal because its standards for a rating were stricter than Moody’s. “We need to address this now in preparation for the future deals,” the analyst wrote.

The lawsuit comes just 18 months after S&P cut its rating on long-term U.S. government debt by a notch. The downgrade followed a contentious debate between the White House and Congress over the raising of the government’s borrowing limit that was resolved at the last hour.

Holder was asked about a possible link between the lawsuit and the downgrade.

“There’s no connection,” Holder said, who added the department’s investigation began in 2009.

At the news conference, acting Associate Attorney General Tony West said documents “make clear that the company regularly would ‘tweak,’ ‘bend,’ delay updating or otherwise adjust its ratings models to suit the company’s business needs.” He said that in 2007, S&P issued ratings it “knew were inflated at the time they issued them.”

S&P countered that the emails were “cherry picked,” that they were “taken out of context, are contradicted by other evidence, and do not reflect our culture, integrity or how we do business.”

It said the government left out important context. For example, one email that says deals “could be structured by cows” and then rated by S&P was unrelated to the types of investments at issue in the government’s lawsuit, S&P said. It said the analyst’s concerns were addressed before a rating was issued.

The lawsuit alleges that S&P knew the subprime mortgage market was collapsing by 2006, yet it didn’t issue a mass downgrade of subprime-backed securities until mid- 2007. The mortgages were performing so poorly “that analysts initially thought the data contained typographical errors,” according to one document cited in the lawsuit.

In a 2007 email, another analyst said some at S&P wanted to downgrade mortgage investments earlier, “before this thing started blowing up. But the leadership was concerned of p(asterisk)ssing off too many clients and jumping the gun ahead of Fitch and Moody’s.”

The government’s case sides with critics of rating agencies who have long argued that the agencies suffer from a conflict of interest. Because they’re paid by the banks that create investments they’re rating, the agencies had to compete for banks’ business. If one agency appeared too strict, banks could shop around for a better rating.

S&P typically charged $150,000 for rating a subprime mortgage-backed security and $750,000 for certain other securities. If S&P lost the business to Fitch or Moody’s, its main competitors, the analyst who issued the rating would have to submit a “lost deal” memo explaining why he or she lost the business.

The government charged S&P under a law intended to make sure banks invest safely. If S&P is found to have committed civil violations, it could face not only fines but also limits on how it does business. There are no criminal charges, which would require a higher burden of proof.

McGraw-Hill shares dropped $2.72, or 5.4 percent, to $47.58 in morning trading Tuesday after plunging nearly 14 percent on Monday after the lawsuit was first reported.

Shares of Moody’s Corp., the parent of Moody’s Investors Service, another rating agency, lost $1.05, or 2.2 percent, to $48.40 in morning trading Tuesday after closing down nearly 11 percent on Monday.