The men were sentenced to 80 lashes each on Monday in the ultra-conservative region of Aceh.
The trial was held behind closed doors. Judges have the right to restrict public access to trials if the case can be linked to marital infidelity.
The two men, 20 and 21 years old, were arrested in April after a member of the public saw them enter a toilet in a park. The police broke into the toilet where the men are said to have kissed and hugged, which the court considers a sexual act.
Aceh is the only region in the country where sharia laws are allowed in the Muslim country. The verdict is the fifth of its kind in the region since the laws were introduced in 2015.
There is no national legislation in Indonesia that prohibits homosexuality.