BEIRUT, Lebanon — Security forces in Saudi Arabia thwarted a militant plot to carry out an attack near the Grand Mosque in the holy city of Mecca on Friday, according to the Saudi-owned Al Arabiya television, citing a statement by a spokesman for the Saudi Interior Ministry.

The authorities confronted militants in three places, one in the Red Sea port city of Jidda and two in Mecca, the statement said. After refusing to surrender, a suicide bomber near the Grand Mosque blew himself up, wounding five security officers and six bystanders.

The statement did not say whether the militants belonged to a specific group or what their ultimate target was. But the jihadists of the Islamic State group have harshly criticized Saudi Arabia and carried out a number of deadly attacks in the kingdom in recent years.

A successful militant attack in Mecca would be a blow to Saudi Arabia, which derives legitimacy in the Muslim world for its stewardship of the holy sites and whose monarch bears the title “custodian of the two holy mosques,” meaning those in Mecca and Medina.