At least five civilians were killed on Friday when a suicide bomber blew himself up near a Shia mosque in Afghanistan's capital, Kabul, according to officials.

As many as 19 others were wounded in the attack close to Hussainia mosque that came two days before Ashura, the holiest celebration in the Shia religious calendar.

Police official Sadiq Muradi said police confronted the suicide bomber as he came through a checkpoint near the holy site, calling for him to stop. It was then when the attacker ignited his explosives, blowing himself up.

"The bomber was grazing a herd of sheep and before reaching his target he detonated himself 140 metres from Hussainia mosque," General Salim Almas, Kabul's criminal investigative director, told AFP news agency.

Najibullah Danish, interior ministry spokesman, said that all victims were civilians.

Kabul's Emergency Hospital tweeted that it had received 19 wounded, including four children.

There was no immediate claim of responsibility, but following the attack the Taliban were quick to distance themselves from the bombing.

"Today's Kabul attack has nothing to do with us. After a thorough investigation we found out that we had no operation in Kabul, and this attack is not linked to us," Zabihullah Mujahid, a Taliban spokesman, said.

There had been fears fighters would strike as Shia Muslims prepare to commemorate Ashura.

The celebration falls on the 10th day of Muharram, which is the mourning period for the seventh-century killing of Imam Hussein, the grandson of the Prophet Mohammed.

The faithful gather to beat their chests and hit their backs with chains until they bleed in commemoration of Hussein's death.

But in recent years the sacred day has been marred by deadly violence.

In 2011, a suicide bomber detonated his explosives in the middle of a crowd of worshippers at the main Shia shrine in Kabul on Ashura, killing 80 people, including women and children.

Afghan officials blamed the bombing - the first major sectarian attack on a key religious day in Afghanistan - on Pakistani group Lashkar-e-Jhangvi.

Last October, gunmen entered the Karte Sakhi shrine near Kabul University and killed 18 people gathering to mark Ashura, an attack claimed by the Islamic State of Iraq and the Levant (ISIL, also known as ISIS) group.

The following day at least 14 Shia were killed in a bombing at a mosque in northern Afghanistan. A few weeks later Baqui ul Ulom mosque in Kabul was targeted when a massive suicide blast claimed by ISIL killed dozens of worshippers.