JAKARTA—Two Indonesian Christians were publicly whipped for gambling, a rare case of non-Muslims being punished here under Islamic law, as the country shifts toward a more politicized brand of the religion associated with the Middle East.

The man and woman are residents of Aceh province on the northern tip of Sumatra island, a province that has imposed strict Shariah law. They were whipped at least six times each on Tuesday by a robed man wearing a mask and wielding a rattan cane. Hundreds of onlookers jeered them as the punishment was carried out on a stage next to a mosque in the provincial capital, Banda Aceh.

Indonesia, the world’s most-populous Muslim-majority country, has long been known for its more moderate form of the religion. It has laws protecting the rights of Christians and other groups, a robust democracy and an open economy attracting investors including Toyota Motor Co. to Samsung Electronics Co. The capital Jakarta has restaurants with female staff in skimpy outfits.

But hard-line Islamic groups have been using the country’s democratic system to promote an Islamic agenda, building support among citizens with charity work and public preaching.

Last year, hard-liners succeeded in a campaign to imprison the Christian governor of Jakarta for blasphemy. Lawmakers are now negotiating a revision of the criminal code, including provisions pushed by Islamic parties that would imprison gay people or unmarried cohabiting heterosexuals.