A security official in Paghman district, where the incident took place, said the gunmen managed to flee the area after the attack.
The source speaking on the condition of anonymity further added that the gunmen opened fire on the security forces, leaving three people dead, including a member of security forces.
No group including the Taliban insurgents has so far claimed responsibility behind the incident.
The anti-government armed militant groups have been attempting to carry out attacks in the main cities of the country, including capital Kabul as part of their annual offensive.
The Afghan security forces managed to foil a rocket attack on Kabul city 9 days ago by seizing two rockets before the militants manage to fire them on the city.
This comes as two rockets were fired on Kabul city which landed in the vicinity of the key diplomatic area, Shashdarak, late last month.
The officials confirmed that the attack did not incur any casualties to the city residents or security personnel.
The rocket attack last month followed days after a deadly suicide attack targeted a mosque in the west of Kabul city ten days ago, leaving at least 32 people dead and scores of others wounded.
The loyalists of the Islamic State of Iraq and Syria (ISIS) terrorist group claimed responsibility behind the attack.
The attack on Baqir-ul-Olum mosque took place almost one and half month after a similar attack ripped through a shrine in Kabul city, leaving at least 18 dead and several others wounded.