Yemeni officials said soldiers were ambushed by al-Qaeda insurgents, while so-called Islamic State's (IS) Yemen branch said it carried out the attack.
At least 12 soldiers and 15 militants were killed in a gun-battle and suicide bombing near Shibam in Hadramawt province, reports say.
Yemen has for months been mired in a war compounded by militant attacks.
Large parts of Hadramawt, Yemen's biggest province, are under the control of al-Qaeda in the Arabian Peninsula (AQAP).
Yemeni security officials said masked men opened fire on pro-government troops and detonated a suicide car bomb at a checkpoint on Friday morning.
Fighting is reported to have gone on for hours afterwards.
Yemeni officials said AQAP had carried out the attack. However, IS' wing in Yemen - a rival of al-Qaeda - said it was behind the assault, which it said had killed 50 troops.
IS has carried out a string of bombings and attacks since the group emerged in Yemen in late 2014.
A Saudi-led coalition has been fighting Houthi rebels and its allies in Yemen since the government was forced into exile in March by a Houthi rebellion.
Since then, the fighting has left at least 5,700 people dead, about half of them civilians, the UN says.
Dozens of troops and militants have been killed in clashes in eastern Yemen, Yemeni security sources say.