Taliban militants attacked key buildings near Afghanistan's presidential palace and the US CIA headquarters in Kabul early this morning.

The attack began when at least one man opened fire with an automatic rifle close to a gate to the palace in one of the most tightly guarded areas of the city.

Reporters at the palace gates for security checks ahead of an event at the US Embassy took cover when the firing started.

A senior government official told Reuters four or five attackers had used fake identify papers to try to make their way through security gates in central Shash Darak district.

One car made it through, but a second vehicle was stopped and those inside began shooting. Grenades were also thrown.

The area is home to the presidential palace compound, but an official said President Hamid Karzai was safe.

The Ministry of Defence, an annexe of the US embassy at the old Ariana Hotel and the US Central Intelligence Agency's Afghanistan station are also based there.

Afghan forces and US servicemen returned fire and explosions resounded through the area.

Children walking to school were caught up in the shooting, but escaped serious injury.

A thick plume of smoke was seen rising from the Ariana at the height of the exchanges.

One of the attackers was killed when he detonated a bomb on his body, the government official said, and three or four were killed by security forces.

At least two Afghan security guards were killed.

US Ambassador to Afghanistan Jim Cunningham condemned the attack and called on the Taliban to once again commit to a peace process.

"We remain steadfast in supporting the Afghan government and people against the scourge of terrorism and the violence directed against them," he said.

The Taliban has said it is willing to take part in peace talks to end 12 years of war with the United States and Afghan President Hamid Karzai's administration.