Eight people were killed when gunmen opened fire on a Shia Muslim religious procession in Pakistan, hospital officials said, in what appeared to be the latest incident of spiralling sectarian violence.

More than 30 others were wounded in the attack on Friday, which began when the procession passed a Sunni seminary.

Rock throwing quickly degenerated into gunfire, said staff at the district headquarters hospital in the city of Rawalpindi.

The clashes began when mourners dragged several people out of a seminary after hearing them shout insults at the procession as it passed by, police officer Afzal Hussain told the AFP news agency. They then killed them, he said.

They also set dozens of shops outside the seminary on fire, he said.

Police tried to stop the clash, but officers were wounded as the two sides threw stones at each other, Hussain said.

An army unit based in Rawalpindi eventually reached the scene and took control. A curfew has now been imposed in the city, provincial officials said.

The Shia Muslims were marking Ashura, an annual Shia day of mourning to mark the death of Imam Hussein, a grandson of the Prophet Mohammad.

Many join long processions where they flagellate, beat or cut themselves to show their grief.

Rawalpindi is a few minutes' drive from the capital, Islamabad, and home to the headquarters of Pakistan's army.

Further details of the attack were difficult to ascertain since the government suspended mobile phone services in much of Pakistan during Ashura, in a bid to try and foil suicide bombers, who have attacked such gatherings in the past and regularly threaten Pakistan's Shia population.

Attacks on Pakistan's Shia, who make up about a fifth of the 180 million population, have worsened in recent years.

Most of the attacks are the work of Sunni Muslim fighters, many of whom are affiliated with banned groups such as the Taliban or Lashkar-e-Jhangvi, which wants to drive all Shia Muslims out of Pakistan.

Hundreds of Shia Muslims were killed in bombings and other attacks last year, including children gunned down on their way to school and doctors heading for work.