Image caption Smoke could be seen rising from the compound after the attack

The US and Afghan presidents have "reaffirmed" their support for holding talks with the Taliban, despite an attack in central Kabul on Tuesday.

Barack Obama and Hamid Karzai agreed in a video conference that a peace process was the surest way to end the violence, the White House said.

They also reiterated their backing for a Taliban office in Doha.

Three security guards and four militants died in the assault on the presidential palace and a CIA station.

The attackers used at least two vehicles similar to those used by international forces, along with fake badges and vehicle passes, which allowed them to get inside the capital's high security zone, police said.

Mr Karzai was inside the palace at the time, but the target appears to have been the nearby Ariana Hotel, which houses the CIA station.

The enemies of the people of Afghanistan once again proved with their failed attack that they are against peace, stability and progress Hamid Karzai, President of Afghanistan

The incident came just days after representatives of the Taliban opened an office in Qatar's capital, ostensibly for starting negotiations about a peace process. The US also announced it would begin formal talks to be followed by the direct Afghan talks.

Mr Karzai objected to the office, saying the Taliban flag and sign saying "Islamic Emirate of Afghanistan" which were initially erected there showed the Taliban were trying to portray themselves as a government-in-exile.

He warned that the High Peace Council, which he has empowered to negotiate for his government, would not take part in any peace talks unless the process was "Afghan-led".

The president relented after receiving reassurances from US Secretary of State John Kerry, who also persuaded the Qatari government to get the Taliban to take down the flag and sign.

'Futility'

Following Tuesday's attack in Kabul, Mr Karzai said the Taliban could not open an office for peace in Qatar and at the same time continue to kill people in Afghanistan.

Recent Kabul attacks 9 March: A suicide bomb attack on the Afghan defence ministry kills nine

A suicide bomb attack on the Afghan defence ministry kills nine 16 May: At least 15 are killed and dozens wounded in a suicide bomb attack on a military convoy in the capital

At least 15 are killed and dozens wounded in a suicide bomb attack on a military convoy in the capital 24 May: A Nepali soldier is killed as well as an off-duty policeman as militants battle security forces in the city centre

A Nepali soldier is killed as well as an off-duty policeman as militants battle security forces in the city centre 10 June: Seven insurgents, including suicide bombers, lay siege to the main airport for four hours before they are killed

Seven insurgents, including suicide bombers, lay siege to the main airport for four hours before they are killed 11 June: Suicide bomb attack kills at least 16 people and injures more than 40 outside the Supreme Court.

Suicide bomb attack kills at least 16 people and injures more than 40 outside the Supreme Court. 18 June: Three killed as bomb targets prominent politician Haji Mohammad Mohaqiq

"The enemies of the people of Afghanistan once again proved with their failed attack that they are against peace, stability and progress in Afghanistan," he said.

US ambassador James Cunningham said the attack had failed to achieve its goals and demonstrated "the futility of the Taliban's efforts to use violence and terror to achieve their aims".

White House spokesman Jay Carney later said that in their video conference Mr Obama and Mr Karzai had both "reaffirmed that an Afghan-led and Afghan-owned peace and reconciliation process is the surest way to end violence and ensure lasting stability in Afghanistan and the region".

"And they reiterated their support for an office in Doha for the purpose of negotiations between the High Peace Council and authorized representatives of the Taliban."

The two leaders also discussed the handover of responsibility for security from Nato to Afghan forces last week, the importance of Afghan-led reconciliation efforts, preparations for Afghanistan's 2014 elections, and negotiations on the bilateral security agreement.

"The two presidents reaffirmed that free, fair, and credible elections would be critical to Afghanistan's future," Mr Carney said.

The BBC's Jane Little in Washington says Tuesday's attack highlights just how difficult the bridge-building process will be.