The firefight between security forces and a group of four armed men started late on Tuesday night after the latter set off a car bomb in the well-guarded diplomatic area of Mazza, damaging a building.
Interior ministry officials said a Syrian policeman, a female bystander and two of the attackers were killed in the gun battle.
State-run Syrian television later said security forces had raided a building in Mazza used by the group and found a cache of arms and explosives.
The building damaged by the car bomb formerly housed UN offices.
"Group members hid in a car and threw hand grenades at security forces," the official news agency SANA quoted an official as saying.
Security forces surrounded the car and sounds of the gun battle echoed through the streets.
"Group members hid
in a car and threw
hand grenades at security forces"
"The result of this exchange of fire between security forces and this terrorist group is that two of the members of the group were killed and two others seriously wounded," the official added.
Witnesses said the four-storey former UN building near the Canadian embassy was gutted.
State television later showed footage of the arms cache, which included rocket-propelled grenades, gas cylinders and bags of yellow powder.
An interior ministry official condemned the attack as an act of terrorism.
"The Syrian Arab Republic, which has confronted all forms of terrorism and continues to do so, condemns this terrorist act," SANA quoted the official as saying.
Residents said the armed group had used rocket-propelled grenades and assault rifles.
"I heard two blasts around 15 minutes apart and then security forces came in and there was a firefight," one local said.
Ambulances and other emergency vehicles rushed to the scene and heavy security was in place throughout the capital.
The building hit by the bomb is also close to the Saudi Arabian and Iranian embassies and the British ambassador's residence.
It formerly housed offices of the UN Disengagement Observer Force, a peacekeeping mission that serves as a buffer on the Golan Heights between Syrian and Israeli armies.