Suicide attacks in Saudi Arabia have targeted Medina and Qatif mosques that left four security officers dead and five others injured.
The bombing at the Prophet's Mosque in the city of Medina was the third attack to hit the kingdom on Monday, following blasts in the cities of Jeddah and Qatif.
Photos of Medina posted on social media showed smoke billowing from a fire outside the mosque where Prophet Muhammad is buried.
"Four security guards were martyred and five others wounded as a result of their opposition to the suicide attacker who detonated explosives near them as he was on his way to the mosque," the ministry said on Twitter.
The blast struck moments before sunset prayers when people were breaking their fast inside the mosque.
The mosque, which is also known as Al-Masjid an-Nabawi, is visited by pilgrims from around the world during the final days of the fasting month of Ramadan.
Qari Ziyaad Patel, 36, from South Africa, was at the mosque when he heard the blast just as the call to prayer was ending.
He said 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," Patel told the AP news agency. "It sounded like a building imploded."
Saudi Arabia's state-run news channel, Al-Ekhbariya, aired live video of thousands of worshippers praying inside the mosque hours after the explosion.
The mosque is considered to be Islam's second holiest site after the Sacred Mosque, or Masjid-al-Haram, which surrounds the Kaaba in the city of Mecca.
Following the attack in Medina, Muslims around the world expressed their outrage.
Iran's Foreign Minister Javed Zarif, writing on Twitter, said: "There are no more red lines left for terrorists to cross. Sunnis, Shiites [Shias] will both remain victims unless we stand united as one."
Mohammed bin Zayed al-Nahyan, the Crown Prince of Abu Dhabi, tweeted: "It's time we work together to save our religion from these deadly criminal gangs."
Around the same time as the Medina blast, two other explosions struck near a mosque in the eastern city of Qatif on the Gulf coast.
Witnesses said a suicide bomber blew himself up outside a Shia mosque without causing any other injuries.
They reported seeing body parts lying on the ground in the city's business district.
"Suicide bomber for sure. I can see the body" which was blasted to pieces, a resident told the AFP news agency.
Nasima al-Sada, another resident, said "one bomber blew himself up near the mosque".
A third witness told Reuters news agency that one explosion destroyed a car parked near the mosque, followed by another explosion just before 7pm local time.
There was no claim of responsibility for the attacks.
Earlier on Monday morning, two security officers were injured as a suicide bomber blew himself up near the US consulate in the Red Sea port city of Jeddah.
Security officers became suspicious of a man near the car park of Dr Suleiman Faqeeh Hospital which is directly across from the US diplomatic mission. When they moved in to investigate, "he blew himself up with a suicide belt inside the hospital parking", the interior ministry said.
In January, at least four people were killed in a suicide attack on a Shia mosque in the eastern al-Ahsa region.
In October, the Islamic State of Iraq and the Levant (ISIL) group claimed responsibility for a suicide bombing at a Shia mosque in Najran, in which at least one person was killed.
ISIL, also known as ISIS, also claimed responsibility for an attack at a mosque inside a special forces headquarters in the city of Abha in August 2015. Fifteen people were killed in that attack.