Security forces in Saudi Arabia foiled a major terror attack on the Grand Mosque in Mecca on Friday (23 June) when a suicide bomber detonated himself near the place of worship. Thousands of Muslims have gathered in the mosque to celebrate the end of the holy month of Ramadan.

Police have arrested five people in connection with the terror plot, including a woman, according to the country's interior ministry. Investigation is underway, it added.

The suicide attack in the mosque area was part of an extensive plan made by three terrorist groups, two of which are based in Mecca while the third operates from Jeddah, security forces reportedly said.

The attack unfolded in the Ajyad al-Masafi neighborhood where the suicide bomber was found hiding in a house. He suddenly opened fire on security forces and later blew himself up when he was pressured to hand himself in.

The explosion led to the collapse of the building the attacker was hiding in. Six people were injured in the incident while five members of the security forces suffered minor injuries, Al Arabiya reported.

The interior ministry tweeted images from the blast site that showed ruins of the building where the attacker detonated himself.

The Grand Mosque, or the Masjid al-Haram, is the largest mosque in the world and is a revered pilgrimage site for the Muslim community. Every year, tens of thousands of Muslims visit the mosque that surrounds Islam's holiest site, the Kaaba or a cube-shaped shrine, as part of their Hajj pilgrimage.

The Saudi kingdom has faced many similar attacks in the recent past, some of which were claimed by Isis. The kingdom is part of a US-led coalition fighting Isis and other Islamist jihadists spread across the Middle East nations, particularly Iraq and Syria.