The men tried to storm a building belonging to Saudi Arabia's mabahith security agency in the town of Al Zulfi, located in a conservative area about 155 miles (250 kilometers) from the capital, a spokesman for the Presidency of State Security said in a statement.
Daesh's official news agency, Amaq, claimed responsibility for the attack in a video later on Sunday, in which four masked assailants pledged allegiance to terrorist group's leader, Abu Bakr al-Baghdadi.
"A group of terrorists launched a desperate attack that was repelled", SPA said, without giving further details.
Three security officials were wounded in the attack.
SPA published a list of the weapons found, which included five explosive belts, 64 locally manufactured hand grenades, two Kalashnikovs, six guns, four bags of organic fertilizers, a telecommunication device, and two laptops.
Online videos showed a vehicle at a checkpoint with its doors open and two bloody corpses splayed on the ground nearby.
The kingdom has seen numerous attacks in recent years by jihadists, including Al-Qaeda and IS, against security forces.
Two gunmen died during the initial exchange of fire with the security forces, while one was killed as he attempted to flee.
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. For two weeks, Saudi security forces battled the militants with the help of Pakistani and French special forces.