Saudi Arabia's King Salman has said he was "heartbroken" over a suicide bombing at a Shi'ite mosque in the kingdom that killed 21 people.

Salman said anyone linked to the attack, claimed by the Islamist militant group Islamic State, or who sympathises with it, will be brought to justice.

"We were pained by the enormity of the crime of this terrorist aggression which contradicts Islamic and humanitarian values," the king said in a message to Crown Prince Mohammed bin Nayef, who is also the interior minister.

"Any participant, planner, supporter or sympathiser with this heinous crime will be held accountable, tried and will receive the punishment he deserves," he said.

The bombing in Saudi Arabia came as tensions between Sunni and Shi'ite Muslims are on the increase in the region. Some clerics in Saudi Arabia, the birthplace of Islam and mainstay of its Sunni denomination, are deeply hostile towards Shi'ites, whom they regard as apostates.

A Sunni militant blew himself up in the al-Qadeeh village mosque in Saudi Arabia's heavily Shi'ite east during Friday prayers, in one of the worst attacks in the kingdom in years.

The Saudi Interior Ministry identified the perpetrator as Saleh bin Abdul Rahman Saleh Qashimi, a Saudi citizen wanted for belonging to IS. The militant group had identified him on Friday by a nom de guerre, Abu 'Ammar al-Najdi.