The men were found guilty of violating strict Islamic laws in conservative Aceh and will receive 85 lashes each.
The pair, aged 20 and 23, were found in bed together by vigilantes in March. They have not been identified.
Gay sex is not illegal in the rest of Muslim-majority Indonesia and this is its first such conviction. Aceh is the only province where Sharia is in force.
The sentence is due to be carried out next week.