By Sayed Hassib

KABUL (Reuters) - A Taliban truck bomb exploded outside a protected hotel compound used by foreign service contractors in Kabul on Monday, ripping a deep crater in the ground and leaving a tangle of wreckage but causing few casualties.

The loud blast was heard around Kabul at about 1.30 a.m. (2100 GMT on Sunday) and electricity was cut off in many areas, heightening uncertainty in a city on edge after a suicide attack a week earlier that killed at least 80 people.

One attacker was killed after detonating his vehicle and two were killed by police in the early hours of the morning, Kabul police chief Abdul Rahman Rahimi said. One police officer was killed and four were wounded.

The explosion outside the Northgate Hotel, a secure residential compound for foreign military and civilian organizations, destroyed light metal structures in an empty neighbouring compound and left debris strewn about but heavy blast walls remained intact.

As day broke in the grimy industrial zone where the hotel is located, gunfire and occasional explosions rang out but the incident was soon over. No casualties were reported from within the hotel.

The attack on a hotel the Taliban said was a "place of vulgarity and profanity" was the latest in a series against foreign targets in Kabul, underlining precarious security in Afghanistan, even in the capital.

It came around a week after the Islamic State militant group claimed responsibility for a suicide attack on a demonstration by members of the mainly Shi'ite Hazara minority, killing at least 80 people.

The Taliban, who say that foreign "invaders" must leave Afghanistan but who often say they want to avoid civilian casualties, said the compound was not near homes and ordinary people were not harmed.

Security officials originally said four attackers were at the site, a walled compound of a type used by foreign security and civilian organizations in Kabul, even though police later said three attackers had been killed.

The Taliban said there were "dozens of dead and wounded". The group often exaggerates the extent of attacks it launches against Afghan government and foreign security targets.

After the attack, Afghan security forces closed off streets around the site, east of Kabul's main airport and on the way to the sprawling Bagram air base north of the capital.

The attack followed the bombing in June of a bus carrying Nepali security contractors working for the Canadian embassy, as well as other attacks on foreigners in Kabul, including a suicide attack on a camp used by foreign contractors in January.

(Additional reporting by James Mackenzie and Hamid Shalizi; Editing by Paul Tait, Robert Birsel)