Parwan province's police chief Haroon Mubarez said on Tuesday the gunmen stormed the mosque when worshippers were offering evening prayers after breaking their Ramadan fast, Aljazeera reported.
It was unclear how many gunmen were involved in the attack.
Afghanistan's Ministry of Interior confirmed Tuesday's attack in Parwan's capital Charekar, blaming it on the Taliban. The armed group denied responsibility.
Earlier on Tuesday, the Taliban launched an attack on Afghan security forces in the northern city of Kunduz, killing eight and injuring several others.
The incident came a week after President Ashraf Ghani ordered the country’s military to resume its operation against the militants following a string of deadly attacks on security forces.
The United Nations has warned of an alarming uptick in violence against civilians and a “striking deterioration” in respect for international humanitarian law in Afghanistan.