Jakarta. Former president Megawati Soekarnoputri was among a slew of former officials who took advantage of free trips to the hajj doled out by the government, even as thousands of Indonesians languish on a waiting list that stretches up to 17 years, a court has heard.

The claim was made at the trial of Suryadharma Ali, the former minister for religious affairs, who is charged, among other things, with embezzling Rp 1.8 billion ($125,800) in funds from his office and of handing out free hajj trips to cronies.

Suryadharma told the Jakarta Anti-Corruption Court on Monday that Megawati was of several officials who hogged dozens of hajj places for themselves and their retinues during the annual pilgrimage to Mecca in 2012.

Indonesia’s hajj quota that year, set by the Saudi Arabian government, was for 220,000 pilgrims, but up to 4,400 of them ended up not being able to go for various reasons, including illness or old age.

Suryadharma said that under the 2008 Hajj Law, he was within his rights to reallocate those slots as he saw fit.

That included giving 50 slots to Megawati and her husband, Taufik Kiemas, who died in 2013; 100 to then-vice president Boediono, who went with a full security detail; 70 to then-defense minister Purnomo Yusgiantoro; and 10 to Amien Rais, a former speaker of the People’s Consultative Assembly (MPR).

Suryadharma himself distributed six free places to his relatives.

The rest of the slots were farmed out among legislators; officials from various state institutions, including the Supreme Audit Agency (BPK), the State Finance Development Comptroller (BPKP), the Central Statistics Agency (BPS) and the Corruption Eradication Commission (KPK); the Indonesian Military; the National Police; and reporters, among others.

“The distribution of the unused quota is in line with the 2008 law,” Suryadharma told the court.

The former minister also stands accused of bypassing the required tender process in appointing 17 Saudi firms and hotel operators to provide accommodation and catering for Indonesian pilgrims in the Muslim holy cities of Mecca and Medina.

The alleged crime “cost the state Rp 27.3 billion and 17.96 million Saudi riyal ($4.79 million),” prosecutors from the KPK said in their indictment.

Suryadharma is also charged with embezzling Rp 1.8 billion of operational funds for his personal use. He claims, though, that he merely “borrowed” the money and had every intention of paying it back (he still has not done so), and that bypassing the tender for the hajj housing project was a necessary move to finalize the pilgrims’ accommodation in time for the hajj.

He faces a maximum life sentence in prison and fines of up to Rp 1 billion if found guilty of all the charges.