In his decision, US Bankruptcy Judge James Peck said that the Bank of America violated federal law when it ‘brazenly’ seized the deposits after having taken advantage of Lehman’s weakened condition in the summer of 2008 in obtaining the money.

“It is difficult to understand how Bank of America could have thought that taking the money was the right thing to do without first seeking permission from the court,” Peck wrote in a opinion filed in Manhattan bankruptcy court.

“The actions taken were surprising and, quite frankly, disappointing for a leading financial institution that should care a great deal about its reputation,” Peck wrote.

In August 2008, shortly before Lehman’s collapse the following month, Bank of America demanded that Lehman deposit the $500m into a cash collateral account and in November 2008, Bank of America seized those funds without first seeking permission of the bankruptcy court.

Bank of America has been ordered by the judge to repay the funds plus interest.

The decision is a major victory for Lehman, which is still trying to repay creditors hundreds of billions of dollars following its bankruptcy in September 2008.