The Interior Ministry said it launched a raid in Jiddah province, as well as two areas in Mecca itself, including the Ajyad Al-Masafi neighbourhood, located near the Grand Mosque.
There, police said they engaged in a shootout at a three-storey house a suicide bomber, who blew himself up and led to the building’s collapse on Saturday.
Five others were arrested, including a woman, it said.
Saudi state television aired footage after the raid near the Grand Mosque, showing police and rescue personnel running through the neighbourhood’s narrow streets.
The blast demolished the building, its walls crushing a parked car as what appeared to be shrapnel and bullet holes peppered nearby structures.
The Interior Ministry “confirms that this terrorist network, whose terrorist plan was thwarted, violated, in what they would have perpetrated, all sanctities by targeting the security of the Grand Mosque, the holiest place on Earth.”
“They obeyed their evil and corrupt self-serving schemes managed from abroad whose aim is to destabilise the security and stability of this blessed country,” the statement said.
The ministry did not name the group involved in the attack.
The ultraconservative Sunni kingdom battled an al-Qaeda insurgency for years and more recently has faced attacks from a local branch of the Islamic State group.
Neither group immediately claimed those arrested, though Islamic State sympathisers online have urged more attacks as an offensive in Iraq slowly squeezes the extremists out of Mosul and their de facto capital of Raqqa in Syria comes under daily bombing from a U.S.-led coalition.