Authorities in Indonesia's conservative Muslim province of Aceh have caned four gamblers inside a mosque's compound.

Hundreds of onlookers watched after Friday prayers as the four were whipped five times each at Al Makmur Lamprit mosque in Banda Aceh, the province's capital.

Chief Prosecutor Husni Thamrin said the four were captured while playing poker in August and police confiscated $76 from them.

It was the second public caning in Aceh in two weeks, and the first since provincial lawmakers passed a new law that punishes gay sex by public caning and subjects non-Muslims to the region's strict interpretation of Islamic Sharia law.

Indonesia, the world's most populous Muslim nation, has a policy of secularism but allows Aceh on Sumatra island to follow a version of Islamic Shariah law.