The Islamic State of Iraq and the Levant (ISIL) group has claimed in an online statement that it carried out a deadly suicide bomb attack at a mosque in Saudi Arabia's Eastern Province of Qatif.

The statement said "the soldiers of the Caliphate" were behind Friday's attack by a suicide bomber "who detonated an explosives belt" in the mosque in the Shia-majority city of Qatif.

The group identified the bomber as Abu Amer al-Najdi, and published a picture of him.

Earlier on Friday, the Saudi interior ministry said in a statement that a suicide bomber had set off an explosion during weekly prayers at a Shia mosque, leaving at least 21 dead.

"It has been established that an individual detonated a bomb he was wearing under his clothes during Friday prayers at Ali Ibn Abi Taleb mosque in Kudeih in Qatif province," the statement, which was carried by the official SPA news agency, said.

The ministry spokesman called the attack an act of terrorism, vowing that "Security authorities will spare no effort in the pursuit of all those involved in this terrorist crime".

Pictures posted on social media purported to show the devastation, with dead bodies strewn across the floor and shattered glass covering the courtyard of the mosque.

Saudi Arabia's Shia population is mostly based in two oasis districts of the Eastern Province, Qatif on the Gulf coast, and al-Ahsa, southwest of the provincial capital al-Khobar.

The community accounts for between 10 to 15 percent of the total population.

The attack was the first to target the Shia community in Saudi Arabia since November when gunmen killed at least eight people in an attack on a religious anniversary celebration, also in the east.