Saudi security forces on Friday prevented an imminent attack on the Grand Mosque in Mecca, the country's Interior Ministry said on state-run TV.
A suspect in the planned attack on the mosque blew himself up in a nearby neighborhood when security forces surrounded a home where the man was hiding, according to the ministry.
The suspect refused to comply with demands to surrender, opened fire on security forces and then killed himself, officials said.
The explosion caused the partial collapse of the building in which the suspect was hiding. Six expatriates were injured and taken to a hospital, and five security personnel received minor injuries, a Saudi Press official in London told CNN.
Five people, including one woman, suspected of involvement in the plot were arrested. Three groups, two based in Mecca and one in Jeddah, planned the attack, the Interior Ministry said.
The Grand Mosque, or the Masjid al-Haram, is the largest mosque in the world and surrounds Islam's holiest site, the Kaaba -- a cube-shaped shrine that worshipers circle during the Hajj, the annual pilgrimage that brings millions of people to Mecca.
Foreign involvement suspected
The Interior Ministry said the identity of the attacker was still being verified but pointed to foreign involvement, according to the state-run Saudi Press Agency.
"They obeyed their evil and corrupt selves serving schemes managed from abroad whose aim is to destabilize the security and stability of this blessed country," the ministry was quoted as saying.
"The security people, with the help of Almighty Allah, and then the unlimited support of the Custodian of the Two Holy Mosques and the Crown Prince, will be able to foil these criminal schemes and arrest those involved in them."
UAE Foreign Minister Sheikh Abdullah bin Zayed Al Nahyan condemned the attempted attack and said his country stood with Saudi Arabia in combating terrorism.
"This heinous crime exposes the extent of terrorism and the savagery of those terrorist groups, and no one in their right mind can justify or explain it," he said in a statement Saturday.
Saudi Arabia has suffered a string of terror attacks in recent years, as well as thwarting a number of alleged plots.
In October, the Interior Ministry said Saudi security forces had arrested two separate terrorist cells, one of which planned to attack a football World Cup qualifying match in Jeddah that month. Four Pakistani nationals were arrested in connection with that plot, while four Saudi nationals were detained from the other cell.
Three suicide bombings were carried out in July last year -- in Medina, Jeddah and Qatif. Saudi authorities identified the Jeddah bomber as a Pakistani; two guards were wounded in the attack, close to the US consulate. The Medina attack, close to one of the holiest sites in Islam, killed four security guards. No group claimed responsibility for the attack, but Saudi officials blamed local cells sympathetic to ISIS.
A Shia mosque in al-Ahsa was targeted in January 2016 in an attack that claimed at least four lives. No claim of responsibility was made, but the attack was believed to have been carried out by ISIS or one of its affiliates.
At least 13 people were killed in an explosion at a mosque in the Asir region of southwestern Saudi Arabia in August 2015 and five more in an attack on a Shia mosque in Saihat, on the country's east coast. ISIS or an ISIS affiliate were blamed.
The kingdom was rocked by two attacks in May 2015, both claimed by ISIS. One suicide bomber killed 21 people at the Imam Ali mosque in Qudayh and another, a man disguised as a woman, claimed three lives when he blew himself up outside a mosque in Dammam.