A suicide bombing outside one of Islam's holiest sites killed four Saudi security forces on Monday, and similar attacks outside a mosque and a US Consulate in two other Saudi cities raised fears of a coordinated assault aimed at destabilizing the Western-allied kingdom.
The Interior Ministry said five others were wounded in the attack outside the sprawling mosque in Medina.
Millions of Muslims from around the world visit the mosque every year as part of their pilgrimage to Mecca.
The ministry said the attacker 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.
No group has yet claimed responsibility for any of the attacks.
Altayeb Osama, a 25-year old Sudanese visitor to Medina and resident of Abu Dhabi, said he heard two large booms about a minute apart as he was heading toward the mosque for sunset prayers. He said police and fire trucks were on the scene within seconds.
"It was very shocking that such a thing happens in such a holy place for Muslims, the second holiest place in the world. That's not an act that represents Islam," Osama said. "People never imagined that this could happen here."
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 mosque was packed 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.
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, but then he felt the ground shake.
"The vibrations were very strong," he said. "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. It also showed footage of Saudi King Salman's son and the Governor of Medina, Prince Faisal bin Salman, visiting security officers wounded in the blast and the site of the explosion.
Also Monday evening, at least one suicide bomber and a car bomb exploded near a Shiite 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.
Saudi Arabia has been a target of Daesh attacks that have killed dozens of people. In June, the Interior Ministry reported 26 terror attacks in the last two years.
Saudi Arabia is part of the US-led coalition fighting the Islamic State group in Iraq and Syria.
The attack in the eastern region of Qatif did not appear to cause any injuries, said resident Mohammed al-Nimr.
Qatif is heavily populated by Shiites, who are a minority in the Sunni-ruled kingdom. Al-Nimr told The Associated Press the blasts there happened when most residents of the neighborhood were at home breaking the daily Ramadan fast.
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.
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.
Interior Ministry spokesman Maj. Gen. Mansour al-Turki said the guards noticed the man was acting suspiciously at an intersection on the corner of the heavily fortified consulate, near a hospital and a mosque. The Interior Ministry did not say whether the bomber intended to target the US diplomatic compound.
No consular staff were wounded in the attack.
The ministry said the bomber was a Pakistani citizen residing in the kingdom.
Authorities identified the attacker as a 34-year-old Pakistani driver named Abdullah Qalzar Khan, who lived with his wife and family in the city.
There are around 9 million foreigners living in Saudi Arabia, which has a total population of 30 million.
Al-Ekhbariya said security forces detonated six explosive devices found at the scene of the attack near the consulate.
A 2004 al-Qaida-linked militant attack on the U.S. Consulate in Jeddah killed five locally hired consular employees and four gunmen. The three-hour battle at the compound came amid a wave of al-Qaida attacks targeting Westerners and Saudi security posts.