In neighbouring Kuwait, officials arrested four people suspected of ISIS links for plotting attacks.
Local media say the attacker planned to target the sacred site as thousands had gathered for the sunset prayer on the last day of the holy Muslim fasting month of Ramadan.
The head of Saudi Arabia's Shura Council, the kingdom's main government advisory body, called it an "unprecedented" incident.
There has so far been no claims of responsibility, but the Islamic State of Iraq and the Levant (Isil) had urged its supporters to carry out attacks during the holy month and has claimed or been blamed for a wave of shootings and bombings including in Orlando, Bangladesh, Istanbul, Lebanon and Baghdad.
None of them had obtained Saudi identification cards, and it was not immediately clear what country or countries the trio hailed from.
A Saudi security spokesperson said the attackers intentions were "still unclear" since there was a mosque, local security forces, and a US consulate in the vicinity of the bomber, whose vest only partially detonated.
The first attack on Monday took place in the western city of Jeddah, where two security officers were wounded when the suicide bomber blew himself up near the United States of America consulate.
The Interior Ministry said late Thursday the Medina bomber was 26-year-old Saudi national Na'ir al-Nujiaidi al-Balawi.
In the attack, the bomber detonated his explosives after two security guards approached him, killing himself and lightly wounding the two guards, the Interior Ministry said.
Iran, the region's major Shi'ite power, also condemned the attacks.
"It is at its highest levels and, thanks be to God, it gets stronger every day", Saudi Crown Prince Mohammed bin Nayef was quoted by the Saudi Press Agency as saying when he visited three people wounded in Jeddah.
It said in a statement that the ministry and the Consulate General of Malaysia in Jeddah would continue to monitor the development. The city is home to the second holiest site in Islam, a mosque built by the Prophet Mohammed, the founder of Islam, which also houses his tomb. "The attack is a larger conspiracy by these groups, shedding the blood of innocent people in the name of Islam?"