According to Khalil Asir, a spokesman for Takhar police, the clash broke out after local residents stormed a Taliban prison on Monday afternoon.
Asir added the members of the community attempted to get access to Taliban insurgents who allegedly raped two girls in the district two weeks ago.
He said the militants opened fire on the residents which resulted in the death of three people. Three more were wounded.
Two weeks ago, a resident of Khwaja Ghar claimed that Taliban fighters raped two of his teenage daughters.
The local Taliban reportedly denied any wrongdoing. The Taliban has not commented on the incident