Police officer who requested anonymity told Xinhua the attack occurred as the forces were traveling through Il-baq village, outside of Bal'ad town in Middle Shabelle region in southern Somalia.
"The blast hit the military vehicle and killed two of the soldiers. This is the work of the terrorist group, they are always targeting our security forces," the officer said.
Residents in Bal'ad said they heard huge blast followed by gunfire.
"The blast was huge and then we learnt it had targeted Somali security forces in the area," Aways Mohamed, a resident told Xinhua.
The al-Qaida linked group al-Shabab, responsible for previous attacks in Bal'ad town, claimed responsibility for the latest attack.
On June 5, the group killed at least five people including regional MPs and government soldiers near Bal'ad town in southern Somalia.