BEIRUT, Lebanon — The security forces in Saudi Arabia have carried out a nationwide dragnet in recent months that resulted in the arrest of more than 400 people believed to be connected to the Islamic State jihadist group, the Saudi Interior Ministry said on Saturday.

The people who were arrested were linked to recent attacks inside the kingdom; they planned attacks or monitored potential targets, or used social media to spread extremist ideology and entice new recruits, the Interior Ministry said.

The high number of arrests highlights the profound fears inside the conservative, oil-rich kingdom that the jihadists who control territory in nearby Iraq and Syria will sow further trouble inside Saudi Arabia, as the militants’ leaders have vowed to do.

While Saudi Arabia’s strict version of Islam shares some aspects with the one espoused by the Islamic State, the kingdom’s leaders have denounced the group for its wanton violence and mobilized state clerics to condemn its acts. The Saudi Air Force has also joined an American-led coalition bombing Islamic State targets in Iraq and Syria.