Image copyright AFP Image caption Devotees rushed to help the victims following the blast outside the shrine

At least 18 people have been killed and 27 injured in a suicide attack on a Sufi Muslim shrine in Pakistan's south-western province of Baluchistan.

Crowds of devotees had gathered for a religious ceremony in Jhal Magsi, near the provincial capital Quetta.

The bomber reportedly detonated his explosives after being stopped at the gate of the shrine by a policeman. The officer was killed.

So-called Islamic State (IS) later said it was behind the attack.

The IS news outlet Amaq called it "a martyrdom operation".

Sufi shrines have been increasingly targeted by Islamist extremists who view Sufism as heretical.

"The suicide bomber struck outside the shrine at a time when it was packed with people attending anniversary celebrations of Syed Cheesal Shah," said local official Asad Kakar, referring to a Sufi saint.

The police officer's actions in stopping the bomber entering the shrine reduced the number of casualties, Baluchistan home minister Sarfraz Bugti told Reuters.

Security forces have sealed off the building, Pakistani media reported.

In February at least 80 people were killed in an attack on a shrine in Sehwan in southern Sindh province. So-called Islamic State said it was behind that attack.

Sufism is a mystical branch of Islam which spread throughout the Indian subcontinent in the 13th Century.

Sufis believe in saints who can intercede for them directly with God. Several million Muslims in Pakistan are believed to follow Sufism's tenets.