NAIROBI - Kenyan security forces were locked in a fierce, final battle with Somali gunmen inside an upmarket Nairobi shopping mall on Monday as huge explosions and a barrage of heavy gunfire echoed out of the complex.

Thick black smoke billowed for several hours from the Westgate mall as Kenyan officials said the more than two-day-long siege - in which the gunmen have massacred at least 62 people and taken dozens more hostage - was close to being resolved.

"We think the operation will come to an end soon," Interior Minister Joseph Ole Lenku told reporters camped outside the vast part Israeli-owned complex, which was popular with wealthy Kenyans and expatriates. "We are in control of all the floors," he said. "The terrorists are running and hiding in some stores... There is no room for escape." Lenku said most hostages had been freed, without giving specific numbers. The Kenyan Red Cross, which lowered an earlier toll after correcting for double-counting, said at least 63 people were recorded missing, thought to include hostages as well as those possibly killed or still hiding. Around 200 people were wounded, officials said.

Two gunmen were also killed in the fighting. Somalia's Al Qaeda-linked Shebab insurgents have claimed the attack, which began midday on Saturday, when the gunmen marched into the complex, firing grenades and automatic weapons and sending panicked shoppers fleeing.

Kenyan army chief Julius Karangi said the gunmen were of different nationalities. Many foreign fighters, including Somalis with dual nationalities, are members of the Shebab force. "They are from different countries. We have sufficient intelligence this is global terrorism," Karangi said.

Lenku denied that any of the insurgents were women. "There are no women. All the terrorists are men," he said, noting: "Some of them had dressed like women." Shebab spokesman Ali Mohamud Rage warned that the hostages would "bear the brunt of any force directed against the mujahedeen" - signalling that hostages were being used as human shields.

Kenyan President Uhuru Kenyatta vowed that the attackers will "not get away with their despicable and beastly acts." "We will punish the masterminds swiftly, and indeed very painfully," he declared in a televised speech to the nation on Sunday, revealing that a family member - a nephew and his fiancee - were among the dead.

A Kenyan security source and a Western intelligence official said Israeli forces were also involved in the operation, along with British and US agents.

The Shebab rebels said the carnage was in retaliation for Kenya's military intervention in Somalia, where African Union troops are battling the Islamists.

"If you want Kenya in peace, it will not happen as long as your boys are in our lands," rebel spokesman Ali Mohamud Rage said in a statement posted on an Islamist website.

Shocked witnesses said the gunmen tried to weed out non-Muslims for execution by interrogating people on their religion or asking them to recite the Shahada, the Muslim profession of faith.

The dead include four Britons including a British-Australian, two French women, two Canadians including a diplomat, a Chinese woman, two Indians, a South Korean, a South African and a Dutch woman, according to their governments.

Also killed was Ghanaian poet and former UN envoy Kofi Awoonor, 78, while his son was injured. Mall worker Zipporah Wanjiru survived by hiding under a table with five other colleagues. "They were shooting indiscriminately, it was like a movie seeing people sprayed with bullets like that," she said, bursting into tears.

Security camera footage seen by Kenya's The Standard newspaper showed gunmen raking toilet cubicles with a barrage of gunfire, apparently after learning that people were hiding inside.

Cafe waiter Titus Alede, who leapt from the first floor of the mall to avoid being killed, said it was a "miracle from God" that he managed to escape the approaching gunmen. "I remember them saying 'you killed our people in Somalia, it is our time to pay you back'," he said.

Other survivors said they played dead to avoid being killed. While the rest of Nairobi has largely been business as usual, deeply shocked Kenyans turned out in their hundreds to give blood, as well as raising more than $400,000 (300,000 euros) to support the families affected.

Israeli interests in Kenya have come under attack before, and the Westgate mall - popular with well-to-do Kenyans, diplomats, UN workers and other expatriates - has long been seen as a potential target.

World powers condemned the chilling attack, the worst in Nairobi since an Al-Qaeda bombing at the US embassy killed more than 200 people in 1998.

US President Barack Obama called Kenyatta offering support "to bring the perpetrators of the attack to justice", while UN chief Ban Ki-moon said the violence was "totally reprehensible".

Somali Prime Minister Abdi Farah Shirdon said the attackers were "brainwashed into destroying innocent lives, theirs included".

On Monday, the International Criminal Court excused Kenyan Vice President William Ruto from his trial on charges of crimes against humanity over deadly 2007-08 post-election violence for a week so he can deal with the attack. Ruto's lawyer Karim Khan called the siege "Kenya's 9/11".