A police official told the Associated Press, "The explosion resulted from two car bombs that were parked about 50 feet from the building."
He said "a number of charred bodies" were removed from the scene.
The nine people killed included policemen and civilians, staff at three hospitals told the AP. The hospital officials spoke on customary condition of anonymity. Police had earlier told the AP that one body was identified as that of a suicide attacker. It was not immediately known if his body was among those counted by the hospital officials.
The explosions occurred at about 2 p.m. local time, when workers would have been leaving for the Saudi weekend. The bombing came just days after the United States warned of possible terror attacks in the kingdom.
Saudi television showed the seven-story high General Security building with its glass facade shattered and severe damage inside. Firefighters worked to extinguish the blazes, and more than 20 ambulances were on the scene. Police blocked the area and evacuated people in surrounding buildings.
"The front of a building is blown off and smoke is still rising," a Reuters correspondent said from outside the building.
General Security oversees officers who investigate burglaries and murders, direct traffic and carry out other basic police duties. Such officers have been manning checkpoints as part of the Saudi crackdown on Islamic militants. The officers have occasionally clashed with suspects.
Last month, a purported al-Qaida message appeared on the Internet threatening Saudi police, members of the intelligence forces and other security agents. The message said targeting Saudi security agents "in their homes or workplace is a very easy matter."
The Saudi Foreign Ministry is located behind the General Security building in al-Nassiriyah, a central Riyadh neighborhood.
In an interview with the Saudi TV station Al-Ekhbaria, a leading Saudi cleric called the bombing "a dastardly criminal act."
"How can they make these dastardly acts bring them closer to God?" Sheik Abdullah Al-Mutlaq said in an apparent reference to Islamic militants blamed for terrorist attacks in the kingdom.
Wednesday's explosions came only days after Saudi authorities announced they had seized three booby-trapped SUVs loaded with a total of more than four tons of explosives that militants had apparently abandoned after a shootout with security forces.
Last week, Washington ordered non-essential diplomats out of the Persian Gulf state and warned Americans they should leave, citing signs of possible attacks on Western interests.
Deputy Secretary of State Richard Armitage was in Riyadh Wednesday on a previously scheduled visit, U.S. Embassy spokeswoman Carol Kalin told the AP. His visit was uneventful and no Americans were hurt or involved in the bombing, she said.
Suicide bombings at foreign residential compounds in Riyadh killed some 50 people last year, including nine Americans.
The Saudi kingdom, a key U.S. ally and the world's largest oil exporter, is battling a tide of Islamic militancy linked to Saudi-born Osama bin Laden's al-Qaida network.