As the massive crowds pressed forward, a stampede broke out that left at least 31 people dead and another 100 wounded, according to Iraq's health ministry.
The deadly rush began when part of a walkway collapsed during a procession causing mass panic among worshippers.
The day of Ashura, which falls on the 10th of Muharram, commemorates the killing of the Prophet Muhammad's grandson Imam Hussain by a rival Muslim faction in Karbala, in present-day Iraq, in 680 AD.
Another 75 people were injured at the shrine around 100 kilometres (60 miles) south of Baghdad, said spokesman Saif al-Badr, stressing that the toll was not final.
Under ex-dictator Saddam Hussein's Sunni-dominated regime, the vast majority of Ashura commemorations were banned.
The rituals commemorating Husayn's death involve self-flagellation, where some of the mourners even whipped their backs and chests to demonstrate their sorrow. Boys also cut incisions into their foreheads with blades, leaving streams of blood flowing down their faces.
Similar ceremonies took place in the capital Baghdad, the southern cities of Najaf and Basra and around the world.
Earlier in the day, hundreds of thousands of black-clad pilgrims held Ashoura processions amid beefed-up security in Karbala and in the capital, Baghdad, marching through the streets.
This year's commemoration comes amid rising tensions in the Middle East and the crisis between Iran and the US and its ally Israel in the wake of the collapsing nuclear deal between Tehran and world powers.