Another 11 soldiers were wounded, the source said.
The attack came just days after President Abdelaziz Bouteflika, 77, was re-elected for a fourth term following a campaign that portrayed the aging leader as key to continued security for the North African OPEC state.
Since the end of its 1990s war with armed Islamists, attacks are rarer in Algeria. But Algerian officials are concerned about spillover from turmoil in neighbouring Libya where fighters linked to al Qaeda have sought refuge in the remote southern deserts.
AQIM is mostly based in southern Algeria, but over the past few months the army has killed several militants in the northeastern mountains, and security sources say some have been found with weapons traced to Libya.
In January last year, militants raided Algeria's Amenas gas plant near Libya's border, killing 40 oil contractors, most of them foreigners, in an attack that prompted BP and Norway's Statoil to pull their workers out.