Four Taliban fighters entered a luxury hotel in Kabul before being shot dead, officials said, adding that three people were wounded as guests were rushed to reinforced safe rooms.
The attackers hid small pistols in their socks and penetrated several layers of security at the Serena Hotel, a prestigious venue favoured by foreign visitors to the Afghan capital.
Taliban fighters have vowed a campaign of violence to disrupt the Afghan election on April 5.
The gunfire at the hotel on Thursday came on the same day that seven Taliban suicide attackers stormed a police station in the eastern city of Jalalabad killing 10 policemen.
A spokesman for the Taliban said it carried out the attack, according to AFP news agency.
"The four young attackers entered the hotel at about 6pm pretending to be guests and started to attack at 9pm," Sediq Sediqqi, the interior ministry spokesman, told reporters.
"Two guards have been taken to hospital, as well as one foreign national employee of the hotel. All four attackers were gunned down, two of them after they resisted in a bathroom in the hotel."
No guests were reported to have been injured in the attack, during which intense bursts of gunfire erupted inside the hotel as security forces and emergency response teams rushed to the scene.
The attack occurred on the eve of Nawroz, the Persian New Year which is a major holiday in Afghanistan, and the Serena was hosting special evening celebrations.
The Serena, the most prestigious accommodation in the city, was hit by a Taliban suicide attack in 2008 that left eight people dead.