They say at least four Afghan policemen, and two Spanish guards also died in the attack.
Reports say a civilian was also killed in the assault which began late on Friday.
The Taliban said its fighters had detonated a car bomb in the Sherpur district before entering the area.
The Taliban confirmed the deaths of its fighters but its Voice of Jihad website said the gunmen killed 20 Afghans and foreigners. The group has been known to make exaggerated claims in the past which later proved unfounded.
Initial reports suggested that the Spanish embassy was under attack, but Spanish Prime Minister Mariano Rajoy denied this.
Kabul police spokesperson Basir Mujahid told the BBC that the first attacker detonated his explosives at the entrance of the guesthouse.
The other three managed to enter the building, firing randomly on nearby houses.
They were all killed after a gun battle that lasted several hours, Mr Mujahid said.
At least nine people were injured.
It was the latest in a series of raids by Taliban fighters on high-profile targets in Afghanistan.
The assault came just hours after President Ashraf Ghani expressed optimism about the resumption of peace talks with the Taliban.
On Tuesday, at least 50 people were killed in a Taliban attack on Kandahar airport.
All four gunmen involved in a deadly attack on a foreign guesthouse near the Spanish embassy in Kabul have been killed, Afghan officials say.