(updates death toll)
By Katharine Houreld and Duncan Miriri
NAIROBI, Jan 16 (Reuters) - Kenyan security forces have killed all the Somali militants who stormed an upscale Nairobi hotel compound, taking at least 21 lives and forcing hundreds of people into terrifying escapes, the government said on Wednesday.
Fifty people believed to have been in the complex remained unaccounted for on Wednesday afternoon, the Kenya Red Cross said, raising the possibility of a much higher final death toll.
The bloody bodies of five attackers were broadcast across social media as President Uhuru Kenyatta announced the end of a 20-hour overnight siege that echoed a 2013 assault that killed 67 people in the Westgate shopping centre in the same district.
Somali group al Shabaab, an al Qaeda affiliate fighting to impose strict Islamic law, said they carried out the attack in revenge for U.S. President Donald Trump's decision to recognise Jerusalem as Israel's capital.
"The security operation ... is over and all the terrorists eliminated," Kenyatta said in a televised national address, looking drained and grave.
Kenyatta did not specify how many assailants there were, but CCTV clips showed at least five dressed in black, some sporting green grenade belts.
One militant is seen in one clip waiting outside a restaurant before blowing himself up in a cloud of debris just after 3 p.m. (1200 GMT). Another explosion near the entrance gate, possibly a grenade, ignites three cars before four men stroll by firing assault rifles and split into two groups.
One group entered a nearby office building, where they left a grenade in the lobby, a private security professional present during the attack told Reuters. Then they shot into elevators and offices as they searched for victims up to the sixth floor.
The other group raked the restaurant with gunfire. Eventually the militants holed up on or near the top floor of the hotel, taking potshots at those fleeing, he said.
Sixteen Kenyans - including a policeman - an American 9/11 survivor, and a British development worker were among the casualties, police chief Joseph Boinnet said. Three more victims were of African origin but their nationality was unknown, he added.
Some victims had been dining in the Secret Garden restaurant and lay slumped at bloodstained tables, video seen by Reuters showed.
In its two-page statement claiming responsibility, al Shabaab said: "This operation ... (was) a response to the witless remarks of U.S. president, Donald Trump, and his declaration."
Air strikes against the group have intensified under Trump, but Tuesday's attack showed that the insurgents retain the ability to strike outside Somalia's borders.
Neighbouring Kenya, a hub for multinationals and the United Nations, became a frequent target for al Shabaab after Kenya sent troops into Somalia in 2011 to try to create a buffer zone along its long, porous border.
The dusitD2 complex is home to offices of international companies including Colgate Palmolive, Reckitt Benckiser , Pernod Ricard, Dow Chemical ad SAP , as well as the dusitD2 hotel, part of Thai group Dusit Thani.
Hiram Macharia, marketing executive at LG Electronics, said he grabbed a fire extinguisher and headed downstairs after the first blast.
"Then we saw two of the attackers firing at the elevators and we turned back," he told Reuters outside the hotel.
"They were firing twice at each of the elevator doors and the two staircase doors on each floor as they walked up the building. One of them fired at our office doors, entered slightly and then moved on."
Macharia and some colleagues hid under desks, but one person ran to the roof and was shot dead there, he added.
WESTGATE MISTAKES AVOIDED
Security forces appeared to have avoided some of the mistakes made during the 2013 attack, when police and soldiers shot at each other, then soldiers looted the Westgate mall.
One private security worker at the scene said many of the explosions, especially those followed by a short burst of gunfire, were Kenyan special forces using small charges to blow open locked doors and clear rooms.
About a dozen armed foreigners of various nationalities were also there, he said, including embassy staff and private security advisers trying to rescue clients.
Mamadou Dia was on a business trip from Paris for STP Consultants when he ended up huddled in a room with Chinese and Canadian hotel guests and a waiter.
"They told us by text that the police knew we were in that room and that they would come, and one and a half hours later, the police came to evacuate us," he said.
As armed officers escorted them out, the attackers shot at them "like snipers," he said, adding that police fired back.
At nearby Chiromo morgue, the family of a 35-year-old man collapsed upon hearing a body had arrived with his identification papers.
"He is gone, he is gone," the father repeated into his phone as his mother wrapped a shawl around herself and wept.
(Additional reporting by Katharine Houreld, John Ndiso, Humphrey Malalo, David Lewis, Hereward Holland and George Obulutsa; Writing by Katharine Houreld; Editing by Alexandra Zavis and Gareth Jones)