The attack on Monday happened as soldiers were travelling between the towns of Biu and Damboa.
Borno state has been at the heart of the jihadist insurgency that has killed 20,000 people and displaced 2.6 million more since 2009.
“Our men fell into an ambush by Boko Haram terrorists while on their way to Damboa from Biu,” a military officer told AFP.
“They fought the terrorists and we lost two men in the fight.”
A military vehicle was also seized in the attack, he added.
Despite repeated claims from the authorities in Abuja that they have “crushed the terrorists”, attacks and suicide bombings persist in hard-to-reach rural areas and outlying towns.
Last week Boko Haram militants stormed a girls’ school in Dapchi, in neighbouring Yobe state, and abducted more than 100 schoolgirls.
The raid comes four years after 276 girls were taken from a school in Chibok, in Borno state.