(Bloomberg) -- Wells Fargo & Co. bungled the 2020 sale of Occidental Petroleum Corp. shares on behalf of an employee trust, leading to millions of dollars in losses when the bank failed to execute trades as planned before the Covid-19 pandemic tanked the stock market, a judge in Texas ruled.

US District Judge Lee Rosenthal of Houston said she will decide later how much the bank must pay Occidental in damages, after lawyers provide more detail on losses suffered by the energy company’s so-called rabbi trust, which was used to compensate certain executives.

The value of the assets held in the trust was “$39.4 million less than they would have been had the stock been sold according to the parties’ agreement,” Rosenthal said in a 38-page ruling handed down Wednesday. The judge indicated the final damage award may be higher because Occidental claims it lost the opportunity to invest the cash it had hoped to receive.

In an emailed statement Friday, Wells Fargo said, “We are disappointed with the ruling and will continue to defend the case.”

The bank had agreed in December 2019 to sell equal daily tranches of 381,420 shares for a week, beginning Jan. 6, 2020, when prices were around $45 to $47 a share, court filings show. An employee who’d never handled such a large transaction sold 381,420 shares on one day in January and sold no shares at all on three of the planned days, records show.

By early March, Occidental’s shares were near $11 a share. On March 20, two months after the agreed sale period, the bank dumped 1.1 million shares in a bulk transaction, driving the company’s shares to $9.98. That kind of price collapse was what the oil company had hoped to avoid through a staged sale that didn’t flood the market with shares.

Rosenthal also denied Wells Fargo’s bid to shift at least some of the blame to Occidental and its custodial intermediary, which also mishandled aspects of the planned share sale. The judge gave the parties until Sept. 9 to outline how she should proceed.

The case is Occidental Petroleum v. Wells Fargo, 4:21-1126, US District Court, Southern District of Texas (Houston).

(Updates with comment from Well Fargo.)

©2022 Bloomberg L.P.