The pair, aged 20 and 23, received 83 strokes of the cane each after being found guilty of breaking sharia rules in conservative Aceh province, the only part of Indonesia that implements Islamic law.
They were led onto a stage set up outside a mosque in front of a crowd of thousands, who jeered and booed loudly.
The pair, whose identities have not been revealed, bowed their heads as they were whipped by officials who wore dark robes and masks with eye slits, and used thin rattan canes.
One of the men grimaced occasionally and the other showed little emotion.
Before the caning, Abdul Gani Isa, a member of the Acehnese clerics' council, told the crowd the caning was "a lesson for the public".
"Lessons carried out with our sharia law are conducted in a very thoughtful way, are educational and do not violate human rights," he said.
Their sentences, which were carried out in the provincial capital Banda Aceh, were reduced by two strokes of the cane due to time already served in detention. [Special Broadcasting Service Corporation] Read more