Many pilgrims have walked to the Shi'ite holy city from towns across Iraq to mark the end of the 40-day mourning period for Imam Hussein , who was killed in a battle nearly 14 centuries ago .