The incident occurred just after midnight on the outskirts of Kunduz city, which was briefly captured by the Taliban last year in a blow to Afghan forces.
“The two soldiers fled after killing 12 sleeping colleagues in the Zakhil Khoman area of Kunduz,” senior local police commander Aziz Kamawal said.
“We have launched an investigation into the incident.”
Mahmood Danish, the Kunduz governor’s spokesman, gave a higher toll of 13 and said the rogue soldiers prepared the way for the Taliban to storm their checkpoint and carry out the killings.
“The police have launched a search operation to find the rogue soldiers,” he said.
Insider attacks have plagued both Afghan and international troops in the country, depleting morale and causing mistrust within security ranks.
The killings come as Afghan forces suffer record casualties as they battle the Taliban without the full support of NATO forces, which ended their combat operation at the end of 2014.
Authorities estimate about 5,000 local police and troops were killed in 2015 – with an additional 15,000 wounded.
NATO, which now helps to train and advise Afghan forces, warns the grim numbers are set to increase this year.