THE glitzy Gulf states take pride in superlatives. They have the world’s tallest building, the biggest shopping mall, even (for a time) the most expensive cocktail. To that list, add a slightly less glamorous entry: what a judge has called one of the largest Ponzi schemes in history. On June 1st a court in the Cayman Islands issued a verdict in the long-running saga of Ahmad Hamad Algosaibi & Brothers Company (AHAB), a conglomerate. When the Saudi company defaulted in 2009, its creditors scrambled to recoup billions in losses. The effective bankruptcy touched off lawsuits from Saudi Arabia to Switzerland. At last, after the longest trial in Cayman Islands’ history, it is one step closer to resolution.

No one emerged from court looking good. Central to the case was whether the founding Gosaibi family knew about fraud carried out by Maan al-Sanea, one of their firm’s executives. Born to a Kuwaiti family, Mr Sanea married into the family in 1980 and soon took charge of AHAB’s financial-services division. Then he started borrowing. The Money Exchange, one of the firms he oversaw, took out more than $120bn in loans between 2000 and 2009. Much of it was “name lending”, unsecured credit extended solely on the borrower’s reputation. When Mr Sanea’s empire collapsed in 2009 in the financial crisis, it had defrauded more than 100 banks. His firms took out more than 12,500 loans during a nine-year period; at times, 20 of them matured each day.

The Gosaibis claimed to know none of this. AHAB filed a $4bn lawsuit against Mr Sanea and his Saad Group, another conglomerate, in 2009. It accused him of forging signatures, using the family name to take out unauthorised loans, and siphoning profits to his own firms in the Cayman Islands and elsewhere (he denied the accusations). The case took eight years to wind through the courts. Anthony Smellie, the territory’s chief justice, concluded that AHAB played an “active role” in the fraud. He sided with liquidators for six of Mr Sanea’s companies, who should now be able to recoup some of their losses.

He also dismissed a $5.9bn counter-claim by Mr Sanea and left in place a prior $2.5bn ruling against him. Lawyers for AHAB are considering their options. The Gosaibis had hoped to use the Cayman judgment to pay creditors. There is an automatic right of appeal in the Cayman Islands. But the courts probably cannot hear an appeal until 2019, says Simon Charlton, the chief restructuring officer at AHAB.

Embarrassing as it is—international bankers have long memories, and Saudi businessmen say the AHAB case still comes up in conversations—the ruling could be useful for Saudi Arabia. It wants to see the whole affair go away, and to deepen foreign investors’ trust in the country’s regulatory and legal systems. Muhammad bin Salman, the ambitious crown prince, aims to attract tens of billions in foreign investment to reduce Saudi’s dependence on oil revenues. One of his institutional reforms is a new bankruptcy law, which was approved in February, the kingdom’s first.

Had it been passed earlier, AHAB’s creditors might already have recouped some of their money. Though Mr Sanea lost much of his wealth after the default, he continued to lead a comfortable life in the kingdom’s Eastern Province, ensconced in a palace with a private zoo. But in October the police were dispatched to arrest him for unpaid debts. His assets are being liquidated. Over the past few months, the Saudis have leaned on all parties to reach a deal. At least two Saudi-linked banks were coerced this year into accepting a settlement plan with AHAB, which now has the support of two-thirds of creditors. Under the new bankruptcy law, that will secure a restructuring. A fraud that is nearly as old as the crown prince may be the first proof of the success of one of his big reforms.