Suicide bombers struck two police stations in Afghanistan's capital on Wednesday, killing at least seven people and wounding 17, officials said.

Interior Minister Wais Ahmad Barmak said a total of eight suicide bombers took part in the attacks, one of which was claimed by the Islamic State group and the other by the Taliban.

In the first attack, in western Kabul, the attackers hurled hand grenades and blew themselves up, setting part of the station on fire, Barmak said, adding that a third suicide bomber was shot and killed by police. He said two police were killed in the attack and two police and a civilian were wounded. IS claimed the attack in a brief statement carried by its Aamaq news agency.

The second attack unfolded in the city center, where a suicide bomber struck the entrance to a police station in order to clear the way for another four bombers. Barmak said "two or three" more attackers were holed up in a nearby building, trading fire with security forces. The Taliban claimed responsibility for the attack in a statement sent to media.

Najib Danish, spokesman for the Interior Ministry, said the violence ended after almost seven hours.

Public Health Ministry spokesman Wahid Majroh said a total of seven people were killed and 17 wounded in the attacks.

Both the Taliban and IS frequently target Afghanistan's Western-backed government and security forces. Twin suicide bombings claimed by IS last week killed at least 25 people, including nine journalists who had rushed to the scene of the first attack. It was the deadliest assault on reporters since the fall of the Taliban in 2001.

Elsewhere in Afghanistan, the Taliban advanced on a district compound, officials said Wednesday, with one reporting the capture of the northern district by the insurgents and another saying heavy fighting was still underway.

The battle for the compound in the Bilchirgh district, in the northern Faryab province, came a day after the insurgents captured the district compound in the remote Tala wa Barfak district, in the northern Baghlan province. The Taliban have captured several districts in different parts of the country from Afghan security forces since 2014, when the U.S. and NATO formally concluded their combat mission and shifted to a supporting role.

Mohammad Hashim, a member of parliament from Faryab province, said the Taliban captured the district headquarters in Bilchirgh early Wednesday after more than 40 security forces retreated under heavy fire. He said the Taliban also captured several villages nearby. Provincial police spokesman Abdul Karim Yuresh said the fighting is still underway and that government forces still hold the compound.

The Taliban issued a statement saying they control the district and claiming to have killed 10 security forces.

Elsewhere in Afghanistan, the Taliban attacked a school being used as a voter registration center, killing eight soldiers in the latest in a series of attacks targeting preparations for elections later this year.

Abdul Aziz Beg, head of the governing council in the western Badghis province, said two other soldiers were wounded and one is missing.

"There are many areas in the province under a high security threat, and this site was one of those areas," he said, adding that the center was some 20 miles west of the provincial capital of Qala-e Now.

In the eastern Nangarhar province, a rocket fired by insurgents struck a market, killing two people and wounding 19, according to Attahullah Khogyani, spokesman for the provincial governor. He said another four other civilians were killed and 15 wounded in a gunbattle in the same district, in which two insurgents were killed and seven wounded. It was unclear who was behind the attacks, but the Taliban and an Islamic State affiliate are both active in the province.