Saudi Arabia on Tuesday identified the suicide bomber who struck outside the U.S. Consulate in Jeddah as a Pakistani resident of the kingdom who arrived 12 years ago to work as a driver.

The suicide bombing near the diplomatic post Monday was the first of three targeting the kingdom, including one outside of the sprawling mosque grounds where the Prophet Muhammad is buried in the western city of Medina that killed four Saudi security troops and wounded five. Millions of Muslims from around the world visit the mosque every year as part of their pilgrimage to Mecca.

The governor of Mecca, Prince Faisal bin Salman, who is a son of King Salman, was shown on state television visiting security officers wounded in the blast and the site of the explosion, within hours of the blast.

People never imagined that this could happen here. - Bystander Altayeb Osama

No group has yet claimed responsibility for the Jeddah and Medina attacks, nor another at a Shia mosque in the east of the country. The nature of the attacks and their apparently co-ordinated timing suggested the Islamic State in Iraq and Syria (ISIS) could be to blame.

An Interior Ministry statement issued on Tuesday identified the man as 34-year-old Abdullah Qalzar Khan. It said he lived in the nearby Red Sea port city of Jeddah with "his wife and her parents." The statement didn't elaborate.

There was no immediate comment from Islamabad. There are around nine million foreigners living in Saudi Arabia, which has a total population of 30 million.

Among all foreigners living in the kingdom, Pakistanis represent one of the largest groups.

Cars caught fire

The Saudi ministry said the attacker in Medina set off the bomb in a parking lot after security officers raised suspicions about him. Several cars caught fire and thick plumes of black smoke were seen rising from the site of the explosion as thousands of worshippers crowded the streets around the mosque.

Worshippers expressed shock that such a prominent holy site could be targeted.

"That's not an act that represents Islam," said Altayeb Osama, a 25-year old Sudanese visitor to Medina and resident of Abu Dhabi who heard two large booms about a minute apart as he was heading toward the mosque for sunset prayers Monday. "People never imagined that this could happen here."

The Prophet Muhammad's mosque was packed on Monday evening with worshippers during the final days of the Muslim holy month of Ramadan, which ends in the kingdom on Tuesday. Local media say the attacker was intending to strike the mosque when it was crowded with thousands of worshippers gathered for the sunset prayer.

Policemen inspect the site of a bomb blast close to the Prophet Mohammed Mosque in the holy city of Medina, Saudi Arabia, on Monday. (EPA/Saudi Press Agency)

'Like a building imploded'

Qari Ziyaad Patel, 36, from Johannesburg, South Africa, was at the mosque when he heard a blast just as people were breaking their fast with dates. Many at first thought it was the sound of traditional, celebratory cannon fire, he said.

"I actually felt the ground shake," he said. "The vibrations were very strong. ... It sounded like a building imploded."

State-run news channel al-Ekhbariya aired live video of the mosque filled with worshippers praying hours after the explosion.

The ruling Al Saud family derives enormous prestige and legitimacy from being the caretakers of the hajj pilgrimage and Islam's holiest sites in Mecca and Medina. The attack may have been an attempt to undermine the Saudi monarchy's claim of guardianship.

Saudi Arabia is part of the U.S.-led coalition fighting ISIS, and the militant group views its ruling monarchy as an enemy. The kingdom has been the target of multiple attacks by the group that have killed dozens of people. In June, the Interior Ministry reported 26 terror attacks in the last two years.

In 1979, extremists took over Mecca's Grand Mosque, home to the cube-shaped Kaaba, for two weeks as they demanded the royal family abdicate the throne.

Last year, the Saudi government was accused of gross negligence by regional foes, primarily Iran, after a crush of pilgrims during the annual hajj killed at least 2,426 people and a crane collapse over the Grand Mosque killed 111 worshippers.

Smoke rises from the Prophet Mohammed Mosque in the holy city of Medina, Saudi Arabia. No group has yet claimed responsibility for the Medina attack or two other attacks in the kingdom on the same day. (EPA/Saudi Press Agency)

3 attacks

Also Monday evening, at least one suicide bomber and a car bomb exploded near a Shia mosque in eastern Saudi Arabia, several hours after a suicide bomber carried out an attack near the U.S. Consulate in the western city of Jeddah.

The attack in the eastern region of Qatif did not appear to cause any injuries, said resident Mohammed al-Nimr. His brother, prominent Saudi Shia cleric Nimr al-Nimr, was executed in January after a court found him guilty of sedition and inciting violence for his role in anti-government protests — charges his supporters reject. Qatif is home to many Shia, a minority in the Sunni-dominated kingdom.

The Interior Ministry said it was working to identify the remains of three bodies at the site of blast, suggesting there may have been three attackers.

ISIS and other Sunni extremists consider Shias to be apostates deserving of death, and have previously attacked Shia places of worship, including a suicide bombing on a Shia mosque in Qatif in May 2015 that killed 21 people.

Earlier Monday, near the U.S. Consulate in Jeddah, a suicide bomber detonated his explosives after two security guards approached him, killing himself and lightly wounding the two guards, the Interior Ministry said.

No consular staff were wounded in the attack.