Sporadic gunfire rang out in the area after the Friday evening attack -- in which seven civilians were wounded -- but the Afghan government announced early Saturday that the siege had ended.
"Afghan Police Special Forces have killed all the attackers who were involved in last night terrorist attack in Kabul," information ministry spokesman Sediq Sediqqi said in a tweet.
Four Afghan and two Spanish police officers were killed in the suicide attack at a guest house near the embassy, officials said.
The Taliban claimed responsibility for the suicide attacks in the Sherpoor area. Spokesman Zabiullah Mujahid said, "Suicide attacks started on a guesthouse of invaders in the Sherpoor area of Kabul in the evening."
Spanish Prime Minister Mariano Rajoy called the assaults a terrorist attack, telling reporters that it appeared to have targeted guesthouses near the Embassy.
Taliban spokesman Mujahid said there were heavy casualties.
Video distributed by Reuters news agency showed many security personnel in the area after darkness fell.
One of the suicide bombers detonated an explosives-laden vehicle at the entrance gate of the guest house, opening the way for the other attackers, the Interior Ministry said in a statement.
Special units of the Afghan National Police surrounded the area and killed three suicide bombers, according to the statement. Police also rescued 12 people at the guest house. The operation ended about 5:30 a.m. local time Saturday, the statement said.
The Sherpoor district hosts not only embassies, but also the homes of many expatriates.
Rajoy, speaking in the Spanish port city of Alicante, told reporters that a Spanish police officer was injured.
Emergency, an Italian aid group that runs a hospital about 700 meters from the Spanish Embassy, said it received seven Afghan patients after the assault.
An anonymous source said most of the Spanish Embassy's staff were in a safe place, though officials were trying to account for the whereabouts of all personnel.