Seven security officers were wounded in the clash on Tuesday, a Saudi journalist told Aljazeera.
"Three terrorists have been killed," said Brigadier-General Mansur Turki, security spokesman at the interior ministry. He added that the ministry was checking the men's identities.
Security forces stormed a building in the eastern Nahda district of Riyadh at 2.30am (2330 GMT on Monday), killing all the men inside, Turki said.
The Saudi journalist told Aljazeera the house had been under surveillance. Armed men opened fire using rifles and hand grenades when the forces raided the house.
A house-to-house search operation had been under way in the neighbourhood since Monday.
The situation was sensitive, as at least seven women and children were inside the house, the journalist said.
They were evacuated before the clash occurred.
Saudi Arabia has been intensifying its clampdown on anti-government fighters since May last year when bombers struck at three residential compounds in Riyadh, killing 35 people.
More than 160 people have been killed since then, including Saudis, foreigners, security forces and fighters.