A gunbattle broke out between security forces and an unknown number of attackers in Kabul, shortly after a loud blast was heard in the western part of the Afghan capital, a police official has said.

Fighting was under way near a district police headquarters located close to a military training school, said the official, who declined to give his name because he was not authorized to talk to the media.

At least two gunmen were firing on the military school and the police headquarters in Kabul's sixth district.

A spokesman for the Taliban claimed responsibility for the ongoing violence, saying militants had attacked three targets in Kabul and caused heavy casualties. He provided no further details.

No official word on casualties was available.

The explosion was large enough to be heard on the other side of the city.

Last month, a suicide bomber killed at least 20 people outside the Supreme Court in Kabul. The extremist group Islamic State claimed responsibility for that attack.