A suicide bomber detonated a car loaded with explosives outside a military academy west of the Algerian capital on Friday, killing at least 18 people.
At least 20 were wounded at the academy in Cherchell, which lies west of Algiers.
The death toll was expected to rise, according to the Sidi Ghilas hospital where the victims were taken.
The officials, who spoke on condition of anonymity, citing policy, gave conflicting tolls, and it was not clear whether those killed were troops or civilians.
Friday was a sacred day in the Muslim calendar that falls toward the end of the holy month of Ramadan, and it is often accompanied by attacks.
Although no one immediately claimed responsibility for the attack, similar assaults have been blamed on al Qaeda in the Islamic Maghreb.
The latest attack comes 12 days after a suicide car bombing of a police station in Tizi Ouzu wounded 29 people.
That attack was claimed by the Islamist group al Qaeda in the Islamic Maghreb (AQIM), which is active in the region.
Islamist extremists have battled Algerian security forces since 1992 when the army cancelled a national election that a now-banned Muslim fundamentalist party was poised to win.
Security forces gained the upper hand over the years, but sporadic attacks continue and increased dramatically in July. An estimated 200,000 people civilians, insurgents and security forces have been killed since the violence began.