Saudi Arabian police foiled a "terrorist action" against Islam's holiest site on Friday, where millions of faithful from around the world have gathered, the state Al-Ekhbaria news channel said.

Citing the Ministry of the Interior, it said 11 people were injured in the collapse of a three-storey building where a suicide bomber had barricade himself and exploded. Five of the injured were police.

It said a terrorist attack had been planned against Mecca's Grand Mosque, where Muslims from around the world have converged for the conclusion of the holy Ramadan fasting month.

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.

Near the end of Ramadan last year in the Saudi city of Medina four people 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, and which the US Central Intelligence Agency said bore the hallmarks of Isil.