Suspect Tayeh al-Saihari, who had been wanted by authorities for his alleged involvement in "jihadist attacks", was spotted in a house in a northern Riyadh neighbourhood, a ministry spokesman said.
In a statement carried by the official Saudi Press Agency, the spokesman said that Saihari was with Talal al-Saidi, also wanted by the authorities on suspicion of belonging to "jihadist groups", AFP reports.
Security forces surrounded the house at dawn and ordered the suspects to surrender but they refused and opened fire on the police who then launched an assault, killing them both, he said.
The interior ministry said two explosive belts "ready to be activated" were found in the house, as well as a homemade bomb and material that could be used to make explosives.
It said that Saihari had "prepared the explosive belts that were used in suicide attacks", including the deadly bombing of a headquarters of the special forces in 2015 and near the Prophet's Mosque in Medina last July.
The Islamic State group claimed responsibility for the attack that killed 15 people.
But no one claimed responsibility for a July 2016 attack in Medina in which four security guards were killed.
Since late 2014, ISIS has claimed a series of bombings and shootings against Shiites in the Sunni-majority kingdom, as well against security forces.
12