Six people were publicly flogged in Indonesia's conservative Aceh province on Tuesday for breaking local Islamic law, despite widespread bans on mass gatherings over coronavirus fears.

Officials insisted they followed social distancing rules but vowed that the global pandemic wouldn't stand in the way of doling out justice.

"To comply with current conditions, we're trying to cut unnecessary procedures like the usual opening speech," said Safriadi, the official responsible for Sharia punishments in provincial capital Banda Aceh.

"We just carried out the flogging directly to make it simpler. Whipping will still go on, but we're limiting the number of people involved," added Safriadi, who goes by one name.

Most of the offenders whipped Tuesday were not wearing protective face masks, and images from the scene suggested some participants came into close contact with each other.

Aceh's public whippings -- widely criticised by rights groups -- can attract hundreds of spectators.

But only about a dozen onlookers turned up at a building inside a public park to see four men flogged 40 times each for drinking alcohol.

An unmarried couple caught together in a hotel room were also given over two dozen lashes from a rattan cane.

Aceh, on the western tip of Sumatra is the only region in Muslim-majority Indonesia to impose Islamic law.

The province allows whipping for a range of charges including gambling, adultery, drinking alcohol, and having gay or pre-marital sex.

Despite the painful punishment, one man whipped for drinking alcohol -- who also served a three-month jail term for the offence -- said he was relieved to be free to join his family for the fasting month of Ramadan, which starts this week.

"I got bored in prison and now I'm finally a free man," he said.

"Ramadan is coming and I couldn't imagine fasting in prison."