Alerted that a drug shipment was on the way, the troops staked out an area in Tambon Winga Phang Kham, Mae Sai district.
They saw seven armed men, each wearing a backpack, walking in Doi Nang Non Forest near the village of Pha Mee (Moo 6), less than a kilometre from the border.
When confronted, the men opened fire.
The exchange of fire ended after 15 minutes but the soldiers held back until the following morning as a precaution.
Daylight on Sunday revealed five dead bodies whose backpacks and three other sacks together contained 720,000 meth pills.