Media playback is unsupported on your device Media caption The BBC's Bilal Sarwary witnessed the attack in Kabul: “We were forced to run”

Afghan security forces have put down a militant gun and bomb attack near the presidential palace, in one of the most secure areas of Kabul.

Officials say four insurgents and three security guards died. The Taliban say they carried out the attack.

President Hamid Karzai was in the palace, but the target appears to have been the nearby Ariana hotel, which houses a CIA station.

This is the latest in a string of attacks on Kabul in recent months.

Most recently a suicide bomber in the capital targeted a prominent Afghan politician on 18 June, just hours before Nato formally handed security responsibility to the Afghan forces.

At the scene It was a close brush with death for a group of nearly 20 Afghan colleagues including myself. We were at the palace gates to attend a press event with President Karzai - and security restrictions dictated we arrived hours prior to the event. As we waited to get inside, there was suddenly gunfire followed by loud explosions 10-15 metres away. We had found ourselves in the middle of the fighting. As presidential guards exchanged fire with insurgents, personnel from the Ariana hotel, the home of the CIA for the last 12 years, also returned fire in self defence as their building came under direct fire. The fighting intensified in a matter of minutes. We took what little cover there was near a wall for the next 40 minutes. An eight-year-old boy, crying and stuck in the fighting on his way to his school, also sheltered with us. This attack caused no civilian or military casualties but this is a huge propaganda victory for the insurgents as they have managed to infiltrate one of the safest places in the country.

With this attack the Taliban infiltrated one of the most heavily-guarded areas of the capital, with several key buildings such as the defence ministry and Nato headquarters located very close by.

The Afghan Taliban have showed no sign of abating their assault on security targets, despite last week's announcement that they had set up an office in the Gulf state of Qatar for peace talks.

In another attack on Tuesday, at least 10 civilians, including eight woman were killed when a roadside bomb hit their vehicle in Afghanistan's southern Kandahar province.

President Karzai raised strong objections to the Taliban office, saying the flag and nameplate initially erected at the building showed they were trying to portray themselves as a government-in-exile.

Officials say the High Peace Council, the Afghan government body set up to lead peace efforts, would not take part unless the talks process was "Afghan-led".

News conference

The attack near the presidential palace, in the central district of Shash Darak, began at about 06:30 local time (02:00 GMT).

The militants initially targeted the palace's eastern gate - a few hundred metres from the actual building - where dozens of journalists had gathered for a news conference with Mr Karzai scheduled for 09:00.

The BBC's Bilal Sarwary, who was among the crowd of journalists, says they were forced to run for cover as bullets flew overhead.

The journalists heard several explosions, and reports said grenades were being thrown. Tolo TV reported as many as 14 blasts.

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

Our correspondent says the area around the palace, which is patrolled regularly throughout the day by special forces and intelligence agents, is now under lockdown.

Taliban spokesman Zabihullah Mujahid said in a text message: "A number of martyrs attacked the presidential palace, defence ministry and the Ariana Hotel."

The Ariana Hotel is known to house a CIA station.

Kabul's police chief, Ayub Salangi, said the attack was brought to an end just under two hours after the first shots were fired.

Four attackers wearing uniform and carrying fake ID cards began the attack, with one blowing himself up, a defence ministry spokesman told the BBC. They were eventually killed by private security forces attached to the hotel.

The Nato-led International Security Assistance Force, whose headquarters is also not far from the scene of the attack, wrote on Twitter that the Afghan National Security Forces had led "the response efforts".

Image caption Police say the attack was brought to an end just under two hours after the first shots were fired

Last week, Afghan forces assumed security responsibility for the whole of the country for the first time since the Taliban government was ousted in 2001.

International troops will remain in Afghanistan until the end of 2014, providing military back-up when needed.