RIYADH (Reuters) - Four alleged Islamic State militants were killed on Sunday when authorities thwarted an attack on a state security building in Saudi Arabia’s central Riyadh province, authorities told state media.

The four had helped carry out the attack at the Mabaheth (domestic intelligence) station in Zulfi, a small city about 250 kms (155 miles) northwest of the capital Riyadh, a spokesman for Saudi state security said.

Three security force members were injured in the attack, the spokesman said, adding that security services were dealing with “explosive materials” and other items left behind during the incident.

Online videos, which Reuters could not immediately verify, showed a car at a checkpoint with its doors open and two bloody corpses splayed on the ground nearby. Gunshots could be heard.

Saudi-owned Al Arabiya television said the attackers had been carrying machine guns, bombs and Molotov cocktails.

Islamic State’s official news agency Amaq claimed responsibility for the attack in a video later on Sunday in which four masked assailants pledged allegiance to Islamic State leader Abu Bakr al-Baghdadi.

Reuters could not independently verify the claim and authorities did not officially identify the assailants.

Militants have targeted security installations for years in Saudi Arabia, the world’s top oil exporter, after the authorities crushed an al Qaeda insurgency more than a decade ago.

Last year, a member of the security forces and a Bangladeshi resident were killed in an assault on a security checkpoint in nearby Buraidah, and a policeman was killed in a separate attack in the western city of Taif.