KHOST, Afghanistan — A bombing deep inside an army base in Afghanistan during Friday prayers at a mosque killed at least 27 soldiers and wounded dozens, officials said, once again highlighting the vulnerability of the country’s security forces.

The attack was inside the headquarters of the Afghan Army’s 1st Brigade, 203rd Corps, in the southeastern province of Khost, said Capt. Abdullah Sargand, a brigade spokesman.

A senior official said at least 27 soldiers had been killed and an officer inside the base said more than 20 died. But other officials gave varying accounts of the casualty toll, some lower.

“The explosion happened when army personnel were getting ready to pray,” Captain Abdullah said.

Gul Mohammad-din Mohammadi, the deputy head of Khost’s public health department, said 79 wounded soldiers had been taken to hospitals. Jawed Ghafoor, a spokesman for the Afghan Ministry of Defense, said helicopters had reached the base to evacuate the wounded.