Bank of America Corp.’s Countrywide Financial unit was exonerated of allegations that it sold defective residential mortgage loans to Fannie Mae and Freddie Mac with an appeals court throwing out a judgment against the bank of more than $1.2 billion.

Prosecutors failed to prove at trial that the bank intended to defraud the government, the three-judge appeals panel in New York ruled on Monday. The government only showed the bank sold mortgages that it knew weren’t of the quality promised in its agreements. As a result it might be liable for breach of contract, but not fraud, the panel said. The court ordered the trial judge to enter a judgment in favor of the bank.

The U.S. could ask the entire panel of the federal appeals court judges to re-hear its challenge to the decision.

“We are pleased with the appellate court’s decision,” Lawrence Grayson, a spokesman for the Charlotte, North Carolina-based bank, said by phone. He declined to comment further. Jim Margolin, a spokesman for Preet Bharara, the U.S. Attorney in Manhattan, declined to comment.

The Justice Department in its 2012 complaint claimed the bank and Countrywide generated thousands of defective loans and sold them to the two home-mortgage finance companies now under government control. Countrywide sold the loans to boost revenue in the tightening credit market in mid-2007, according to the lawsuit. The program was called “HSSL,” or the “Hustle.”

Bank of America, which acquired Countrywide in 2008, was among 17 financial institutions sued in September 2011 by Fannie Mae and Freddie Mac’s regulator, the Federal Housing Finance Agency, over losses on mortgage securities sold to the companies.