Police chief Dawlat Khan Zadran said the incident took place in Yayakhil district.
Bowal Khan, chief of Yayakhil district, said the gunman was assigned to a command post when he woke up at 3am for guard duty. He then used his assault rifle to kill the nine men sleeping inside the building, took their weapons and loaded them onto a pick-up truck.
The motive for the killings is not known, but local police blamed the Taleban for the attack.
“This man is a coward. What he did is part of the Taleban conspiracy,” Mr Khan said.