At least nine people, including five foreigners and three guards, have been killed in an attack by gunmen on a luxury hotel in the Libyan capital of Tripoli on Tuesday, The Washington Post reported.

The situation was described to be "under control" on Tuesday afternoon at the hotel, which was reportedly housing Italian, British and Turkish guests, Mahmoud Hamza, commander of the so-called Special Deterrent Force, told private satellite television station al-Nabaa.

In a brief statement on Twitter, the Tripoli branch of the Islamic State jihadist group claimed responsibility for the attack, the SITE Intelligence monitoring group said, adding that the militants portrayed the attack as retaliation for U.S. action in the area, namely the abduction of Nazih Abdul-Hamed al-Ruqai, also known as Abu Anas al-Libi, by American commandos.

On Tuesday afternoon, an unknown number of armed militants stormed inside the Corinthia Hotel, which is a major hub for diplomatic and government activity in Tripoli, and opened fire randomly at staffers, immediately after having set off a car bomb outside, Issam al-Naass, a spokesman for the security services, said.

According to a security official's account, the gunmen killed three guards and took an unknown number of hostages, Reuters reported.

However the standoff ended when the assailants got surrounded by security forces after they made it to the 24th floor of the hotel. But before they could be arrested, the gunmen set off a grenade that left them dead, multiple news agencies reported.

"After being pursued and surrounded on the hotel's 24th floor, the attackers detonated explosive belts they were wearing," Naass said.

In the end, the dead included three security guards killed in the initial attack, five foreigners shot dead by the gunmen and a hostage who died when the attackers blew themselves up. At least five others were also injured, including two Filipina employees who got wounded by broken glass from the car bomb explosion.

The hotel, which previously came under attack in 2013 when a former prime minister was abducted there, is known to regularly host the militia-backed Prime Minister Omar al-Hassi, according to a staffer, who spoke on condition of anonymity.

Although al-Hassi was inside the hotel at the time of the attack, he was evacuated safely, Naass said.

Meanwhile, "since the ouster and 2011 killing of Libyan dictator Muammar Qaddafi, the country has been torn among competing militias and tribes vying for power. Libya's post-Qaddafi transition has collapsed, with two rival governments and parliaments -- each backed by different militias -- ruling in the country's eastern and western regions. Tripoli has been hit with series of car bombs and shootings amid the turmoil," the Associated Press reported.