An interior ministry official said in a statement on Saudi Arabian television that security forces had regained control of the consulate after the attack on Monday.
Security sources said the attackers had killed four Saudi
The sources said initially the attackers had taken 18 local staffers hostage but diplomats said they might have been trapped in the building during the shootout. The sources said all staff in the consulate were now safe.
Witnesses said the attackers had hauled down the US flag and burned it after bursting into the mission.
The attackers killed four Saudi
A US embassy spokeswoman said no US diplomats were killed, wounded or taken hostage in the attack.
Earlier, about 200 Saudi police and national guardsmen sealed off the area around the building even as some guardsmen entered the consulate.
Three of the attackers were killed in the shoot-out, while two others were wounded and arrested, the Saudi interior ministry said.
Saudi journalist Adil al-Tiraifi told Aljazeera that the attackers managed to storm the consulate - heavily guarded by Saudi national guardsmen - entering from the immigration and public services gate.
"I heard a heavy exchange of fire," one bystander said.
The US consulate is usually
heavily guarded by Saudi soldiers
Flames could be seen and two black plumes of smoke were rising from the building.
Witnesses also said a car exploded in front of the consulate, and ambulances attended the scene.
A Western executive, quoting officials inside the building, said attackers infiltrated the complex and threw hand grenades.
"Several men breached US and Saudi security and lobbed one or several grenades at the building," he said.
Security sources and US embassy spokeswoman Kalin could not confirm if the attack was caused by a car bomb or grenades.
"The embassy in Riyadh and the missions in Jedda and Dhahran have been closed as a precaution. We are still trying to gather information," Kalin said.
the past two years, and might be linked to al-Qaida or the related Salafi Jihad group.
Saudi journalist Adil al-Tiraifi told Aljazeera the attack was similar to previous incidents in the kingdom in
"Several men breached US and Saudi security and lobbed one or several grenades at the building"
He said those groups had released many threats on the internet, adding there had been threats targeting the US-Saudi relationship.
The groups had been dormant for a long time, the journalist added.