The incident happened around the Grand Mosque, where hundreds of thousands of worshippers gathered for early afternoon prayers on the last Friday of this year's Ramadan, the Muslim fasting month.
Ministry spokesman General Mansour al-Turki told Saudi television that police "foiled the terrorist plan that targeted the security of the Grand Mosque, pilgrims and worshippers."
In dawn raids on Mecca and the Red Sea city of Jeddah officers arrested five suspects, including a woman, before surrounding the bomber's location around the Grand Mosque.
"Unfortunately he started shooting towards security personnel once he noticed their presence in the area, which led to an exchange of fire before he blew himself up," Turki said.
The blast partially collapsed the building where he had taken refuge, injuring the six pilgrims, Turki said.
He added that four had already been released from hospital, and five security men were also slightly hurt.
Since late 2014 Saudi Arabia has faced periodic bombings and shootings claimed by the Islamic State jihadist group.
Purported images from the scene that circulated on social media showed an alley filled with bricks and other debris apparently from a blast.
Video showed what appeared to be a bearded man's head lying among rubble from a collapsed structure.
Counterterrorism capabilities
Near the end of Ramadan last year in the Saudi city of Medina four security officers died in an explosion close to Islam's second holiest site, the Prophet's Mosque.
It was one of three suicide blasts around the kingdom on the same day, in which a total of seven people were believed killed. The others occurred in Jeddah and in the Gulf city of Qatif.
The US Central Intelligence Agency said those attacks bore the hallmarks of IS.
Most of the targets in Saudi Arabia have been the Shiite minority and security forces, killing dozens of people.
IS leader Abu Bakr al-Baghdadi has called for attacks against the kingdom, a member of the US-led coalition battling the group in Syria and Iraq.
Since July last year police have arrested around 40 people, including Saudis and Pakistanis, for alleged extremist links.
Saudi Arabia's counter-terrorism capabilities -- which for years were led by Prince Mohammed bin Nayef -- are well-regarded internationally.
On Wednesday Prince Mohammed was ousted from his posts of crown prince and interior minister, replaced as heir to the throne by King Salman's son Mohammed bin Salman.
Friday's counter-terrorist operation was the first to take place under the new interior minister, Prince Abdulaziz bin Saud bin Nayef, who is in his early 30s.
Prince Abdulaziz is the nephew of the deposed minister.