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.

The incident occurred at around 13:00 (11:00 GMT) on the 4,010m (13,155ft) Lagginhorn mountain.
"The five climbers fell several hundred metres. They all died at the scene," a local police statement said.
The hikers were descending the Lagginhorn when they fell. Police said it was not yet clear what caused the accident.
The BBC's correspondent in Geneva, Imogen Foulkes, says it appears the five were roped together.
A sixth climber who had not made the final attempt at the summit, because he felt unwell, raised the alarm immediately. Police said he had been airlifted to safety by helicopter.
Police confirmed the hikers were all foreign, but said they would not disclose their nationalities until their families had been informed.
Lagginhorn is the lowest of the 4,000-metre chain of mountains in the Alps, about 10km from the Italian border. It is regarded as one of the easier peaks to climb.
Weather conditions in the area were said to be relatively good.
Dozens of troops and militants have been killed in clashes in eastern Yemen, Yemeni security sources say.
[NEXT_CONCEPT]
Five foreign climbers have fallen to their deaths in the Valais canton in the Swiss Alps.