Four militants were killed on Sunday in an attack on a Saudi security services base north of the capital Riyadh, official media said, as the Islamic State (IS) group claimed responsibility for the assault.

Citing a spokesman for the state security services, the Saudi Press Agency (SPA) said three policemen were also wounded in the morning attack. It said a "group of terrorists" tried to "storm the building" but security authorities repelled them, killing four, AFP reported.

The four had attempted to carry out the attack on the Mabaheth (domestic intelligence) station in Zulfi, a small city about 250kms (155 miles) northwest of the capital Riyadh, a spokesman for Saudi state security said, as cited by the Voice of America.

Videos circulating online, which could not be verified by Middle East Eye, appeared to show two bloodied corpses on the ground outside a silver car with its doors open. Inside the vehicle another corpse can be seen. Gunshots can be heard in one video purportedly from the scene.

The kingdom has seen numerous attacks against security forces in recent years by militants, including by Al-Qaeda and IS.

It has also seen clashes between Shia militants and security forces in the eastern provinces.

IS's elusive leader Abu Bakr al-Baghdadi has in recent years called for attacks on Saudi Arabia, which is part of a US-led coalition that has been battling the militants in Syria and Iraq since 2014.

The group has claimed previous attacks in Saudi Arabia, targeting mostly security forces and members of the Shia community, who they view as heretics.

About 15 percent of the kingdom's 32 million population are Shia, although no official figures exist.

On 7 April, two men armed with explosives were killed and two others arrested as they attacked a security checkpoint in a predominantly Shia region in eastern Saudi Arabia, which has seen years of demonstrations against the Sunni royal family.