Huge crowds of black-clad Shiite Muslim pilgrims thronged the Iraqi shrine city of Karbala on Wednesday, weeping and beating their chests in mourning for the seventh-century killing of the prophet's grandson.

Shiites around the world mark Ashura, but attacks on those commemorating bloodshed 1,300 years ago often result in more mourning and loss, including in Afghanistan, where at least 28 people were killed in attacks on Shiites in less than 24 hours.

Fourteen were gunned down at a mosque in Kabul on Tuesday night, while a bomb hit a mosque in northern Afghanistan on Wednesday, killing 14 more, officials said.

Shiites in Iraq too have come under frequent attack, mostly by Sunni extremists of the Islamic State group who regard them as heretics.

Some 30,000 security personnel were on the streets in and around Karbala to protect pilgrims, although attacks inside the city are rare.

The annual Ashura commemorations mark the killing of Imam Hussein by the forces of the Caliph Yazid in 680 AD — a formative event in Shiite Islam.

The pilgrimage draws huge numbers of faithful, with Haider al-Salami, spokesman for the Imam Hussein shrine, saying two million people took part in a ritual run from outside the city to the mausoleum.

Earlier in the day, black-clad pilgrims massed at the shrine to listen to a recitation of the story of Hussein's death, with some beating their chests or heads and weeping in mourning.

Then came the ritual run, followed by the burning of a tent representing Yazid's forces destroying Imam Hussein's camp — the last of the rituals.

"We will continue to commemorate the imam despite terrorist threats," said Saad Jassem, a 35-year-old from nearby Najaf, another Shiite shrine city.

Fellow pilgrim, Karim Hussein, 40, from the southern port city of Basra, said taking part carried a message for corrupt Iraqi politicians, who have come under mounting fire over the past two years but have done little to reform.

– Message to corrupt politicians –

It is "a message to the politicians to fix themselves, because he (Imam Hussein) rose up and revolted against corrupt rulers".

In Lebanon, thousands of Shiite faithful gathered in Beirut's southern suburbs, where Hezbollah chief Hassan Nasrallah made a relatively rare public appearance on the occasion of Ashura.

Referring to Shiite rebel forces who are the target of a Saudi-led campaign in Yemen, Nasrallah praised "their bravery and their foresight and their faith and their defence of their dignity and their people and their honour."

The appearance came just days after an air strike apparently carried out by Saudi-led forces hit a funeral for the father of a rebel leader in Sanaa, killing more than 140 people.

Imam Hussein's death was part of a dispute over who should succeed the Prophet Mohammed, which eventually developed into a bitter schism between the Sunni and Shiite branches of Islam.

Some Muslims, who became known as Shiites, believed that a blood relative of the Prophet Mohammed should succeed him as the spiritual and temporal leader of Muslims, and backed his cousin and son-in-law Ali — Hussein's father — as successor.

Others, now known as Sunnis, insisted that relationship to the prophet by blood was not required — a position that carried the day for his three immediate successors before Imam Ali became the fourth.

Muawiyah, who founded the Umayyad dynasty, took power as caliph on Ali's death, and, according to Shiite tradition, named his son as successor in violation of an agreement under which Hussein should have succeeded.

According to Shiite belief, Hussein went knowingly to his death at the hands of Yazid's forces in what is now Iraq in a bid to expose the corruption and irreligiosity of his rule.

This ideal of self-sacrifice is a key tenet of Shiite Islam to this day, inspiring followers to give their lives for causes, including the war against IS.

Iraqi forces are currently preparing for a final push on Mosul, the last city in Iraq held by IS, which has lost much of the ground it seized in 2014.