Another five Taliban were wounded in the attack on a house in Sayad district in Sari Pul province, the provincial police chief Abdul Qayum Baqizoi told AFP.
A Taliban commander was among the dead, Baqizoi added. The attackers, who were armed with guns and grenades, fled the area.
The Sari Pul governor's spokesman Zabiullah Amani confirmed the death toll.
Attack on Afghan journalists mourned
"Daesh and Taliban have been fighting each other for more than two months in [neighbouring] Jowzjan and Sari Pul, killing hundreds on both sides," Amani said, using the Arabic acronym for the Islamic State group.
The Taliban has not commented on the attack. IS did not immediately claim responsibility.
IS first emerged in Afghanistan in 2014, overrunning large parts of the eastern provinces of Nangarhar and Kunar near the Pakistan border, where it engaged in a turf war with the Taliban.
The group has since expanded north and has been battling the Taliban as well as Afghan and US forces.
While the Taliban is Afghanistan's largest militant group, IS has a small but potent presence in the country and has repeatedly demonstrated an ability to carry out devastating attacks in urban areas, including Kabul.
COMMENTS (2)
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ