The two men were reported to police by residents of their Banda Aceh neighborhood, AP reports.
One resident had apparently taken video footage of the couple, aged 20 and 23, and shared it online. The footage shows one man, naked and obviously in distress, calling for help on his cell phone as the second man, presumed to be his partner, is pushed by a third, who is preventing the couple from leaving.
The men were ambushed in a rented hotel room late last month, according to DW. Residents had apparently grown suspicious of their affectionate behavior and had decided to catch them in the act.
Banda Aceh is the capital of Aceh province, the only province in Indonesia to practice sharia law. An exception was made for Aceh in 2006, part of efforts by the government to end years of fighting between Jakarta and separatist forces in the province.
In 2014, Aceh passed a law making gay sex punishable by caning.
Gay sex is not illegal in the rest of Muslim-majority Indonesia, though proposals to ban it, as well as any extra-marital sex, have been introduced and are currently under judicial review. The country banned "gay" emojis and stickers last year.
Chief investigator for Aceh's Sharia Police Marzuki (who goes by one name) said if found guilty, the couple will be the first to be punished under the new gay sex ban.
"Based on our investigation, testimony of witnesses and evidence, we can prove that they violated Islamic Shariah law and we can take them to court," Marzuki said, according to DW. He also said the two men had "confessed" to being a gay couple.
One hundred lashes can also be meted out for other "morality offenses," including gambling and drinking alcohol. Men can be caned for skipping Friday prayers, women for wearing tight clothes.