Saudi Arabia has arrested 12 Pakistanis and seven Saudis in connection with the suicide bombing on the prophet's mosque in the city of Medina and other attacks in Jeddah and Qatif.

Saudi Arabia said a suicide bomber who attacked the prophet's mosque in the city of Medina on Monday was a 26-year-old Saudi citizen with a history of drug abuse.

Naer Muslim Hamad crossed a parking lot next to the mosque and detonated an explosive belt, killing four soldiers, the state news agency SPA quoted an interior ministry spokesman as saying.

The statement also named three individuals it said carried out attacks on Monday in Qatif. It said none of them had obtained Saudi IDs.

Saudi Arabia's King Salman bin Abdulaziz Al Saud has vowed that his government will "strike with an iron fist".

READ MORE: Is ISIL embracing a new approach?

"The kingdom is fully determined to strike with an iron fist all those who aim at the minds or ideas of our dear young people," Salman said on Tuesday, in an address to the nation for the Islamic feast of Eid al-Fitr.

The Medina attack, 24 hours before the end of the fasting month of Ramadan, drew condemnation from Muslim leaders worldwide.

A bombing near the US consulate in Jeddah on the same day killed only the attacker, and no casualties other than the bomber have been reported in Qatif.

The Saudi interior ministry identified the Jeddah attacker as Abdullah Waqar Khan, a Pakistani national in his early 30s. In a tweet, the ministry said that Khan, a driver, had moved to Jeddah 12 years ago to live with his wife and her parents.

OPINION: ISIL turns 'shock and awe' doctrine against Islam

Pakistan said on Tuesday that it was going to investigate whether the suicide bomber in Jeddah was one of its nationals.

Many observers suspect the Islamic State of Iraq and the Levant (ISIL, also known as ISIS) of being behind the bombings.

The armed group, which controls areas of eastern Syria and northern Iraq, has frequently denounced the Saudi monarchy and has claimed previous attacks on Shia mosques in Qatif and elsewhere in the kingdom.

The group has claimed responsibility for Sunday's car bomb attack on a shopping street in the Iraqi capital, Baghdad, in which more than 200 people were killed.