Bank of America won a victory over the U.S. government Monday when a federal appeals court reversed a lower court decision against the country’s second-largest bank by assets.

The U.S. Court of Appeals for the 2nd Circuit in New York ruled the Charlotte, North Carolina-based bank does not have to pay a $1.27 billion penalty in connection with its Countrywide home-mortgage lending unit.

The court sided with the bank, ruling the government did not have enough evidence to prove Bank of America liable for shoddy home loans dished out by Countrywide Financial before the bank acquired it in 2008.

The loans were extended under a Countrywide Financial program dubbed Hustle (High-Speed Swim Lane, or HSSL), which focused on a large quantity of subprime home mortgages instead of on high-quality loans, with the lender knowing they could be bundled and passed on as securitized debt. The Hustle program was in place before Bank of America acquired Countrywide, but the loans were passed on during the bank’s ownership of it.

The appeals court ruling puts a check on the government’s efforts to maximize penalties on banks over their involvement in creating a massive real estate bubble that began to burst a decade ago.

The U.S. Justice Department accused Countrywide and, by extension, its parent Bank of America of conspiring to unload thousands of toxic loans on government-sponsored enterprises Fannie Mae and Freddie Mac.

“The trial evidence fails to demonstrate the contemporaneous fraudulent intent necessary to prove a scheme to defraud through contractual promises,” U.S. Circuit Judge Richard Wesley wrote in the court’s decision.

To put it another way, the court ruled Bank of America is not liable for Countrywide’s sale of these loans because the government offered no evidence bank executives were aware of any fraudulent activity in either originating the loans or unloading them on Fannie Mae and Freddie Mac.

“This hypertechnical decision is not only a miscarriage of justice but also provides a road map for Wall Street to get away with more fraud in the future,” said Dennis Kelleher, CEO and president of Better Markets, a nonprofit organization that advocates for the public interest in financial markets. “The law should not be interpreted to encourage and facilitate this kind of deliberate criminality.”

In 2013, a federal jury found Bank of America liable at trial. It also imposed a rare $1 million penalty in a civil case against an executive over conduct that helped lead to the 2008 financial crisis and one of the longest periods of U.S. economic contraction since the Great Depression. Monday, the appeals court also tossed that penalty on former Countrywide Financial executive Rebecca Mairone.

During the real estate wreck, banks profited by first buying bad loans from entities such as Countrywide and then dumping mortgage-backed securities on unsuspecting institutional investors such as pension funds to cut their risk at a profit.