By Edmund Blair and Richard Lough

NAIROBI (Reuters) - Gunmen stormed a shopping mall in the Kenyan capital Nairobi on Saturday, killing at least 39 people including close relatives of Kenya's president and children, in an attack claimed by the Somali Islamist group al Shabaab.

Shooting continued hours after the initial assault as troops surrounded the Westgate mall and police and soldiers combed the building, hunting the attackers shop by shop. A police officer inside the building said the gunmen were barricaded inside a Nakumatt supermarket, one of Kenya's biggest chains.

"We got three bodies from this shop," said volunteer Vipool Shah, 64, standing a dozen meters from the supermarket entrance and pointing to a children's shoe shop where blood lay in pools.

Shah turned to a nearby burger bar where piped music still played and food lay abandoned. "And a couple of bodies here."

The attack appeared designed to achieve maximum global impact by targeting a place frequented by Westerners as well as Kenyans.

France said two of its citizens were dead, the U.S. State Department said it had reports that American citizens had been injured, and Britain said its nationals had undoubtedly been affected.

Al Shabaab, which has links to al Qaeda and is battling Kenyan and other African peacekeepers in Somalia, had repeatedly threatened attacks on Kenyan soil if Nairobi did not pull its troops out of the Horn of Africa country.

"The Kenyan govt (government) is pleading with our Mujahideen (holy warriors) inside the mall for negotiations," the group said under its official Twitter handle @HSM_Press. "There will be no negotiations whatsoever at #Westgate."

Another al Shabaab tweet read: "For long we have waged war against the Kenyans in our land, now it's time to shift the battleground and take the war to their land."

President Uhuru Kenyatta said more than 39 people had been killed, among them close members of his own family, and more than 150 others wounded.

Story continues

"We have overcome terrorist attacks before. We will defeat them again," he said in a sombre televised address, promising to hunt down and punish the perpetrators.

The assault was the single biggest attack in Kenya since al Qaeda's east Africa cell bombed the U.S. embassy in Nairobi in 1998, killing more than 200 people. In 2002, the same militant cell attacked an Israeli-owned hotel on the Kenyan coast and tried to shoot down an Israeli jet in a coordinated attack.

GUNMAN DEAD

The Kenyan presidency said on its Twitter feed that one wounded gunman had been arrested, but had died in hospital.

William Hague, foreign secretary of Kenya's former colonial ruler Britain, said: "Such attacks will never weaken our resolve or the resolve of the people of Kenya to defeat terrorism."

Tiles at the mall were smeared with blood, bullet casings were strewn on the floor and shop windows were shattered. A policeman dragged the corpse of a young girl across the floor and laid her on a stretcher. Two policemen lay on the floor with guns trained on the supermarket entrance.

Some local television stations reported hostages had been taken, but there was no official confirmation.

Kenyan forces first entered Somalia two years ago to try to stem incursions by al Shabaab.

Al Shabaab, which Kenya blames for shootings, bombings and grenade attacks against churches and the security forces, had threatened before to strike Westgate, a mall popular with the city's expatriates, as well as other soft targets such as nightclubs and hotels known to be popular with Westerners.

One woman leaving the building told a journalist that one of the attackers had told all Muslims to leave the area. Survivors told Reuters at least one of the attackers was a woman.

Police helicopters circled above shortly after the initial assault as armed police shouted "Get out! Get out!" and scores of shoppers fled the sand-colored stone building. Smoke poured from one entrance and witnesses said they heard grenade blasts.

Others said they saw about five assailants storm the mall.

TERRIFIED SHOPPERS

The shopping center includes a number of Israeli-owned businesses, though it was not immediately clear if these had been targeted specifically. At least four Israeli nationals escaped the assault, one with light wounds.

"As of now, this appears to be an internal Kenyan incident, that is, a terrorist attack but not one that specifically targeted Israelis," an Israeli Foreign Ministry spokeswoman said.

One eyewitness who identified himself as Taha said he had heard the screech of brakes followed moments later by an explosion, and then sustained gunfire from the ground floor.

Satpal Singh, 36, who was in a cafe on the mall's top floor, said he ran downstairs when he heard the gunfire and was shot at near the mall's main exit.

"A Somali guy shot at me. The guy who shot me was carrying a rifle, an AK-47."

Some shoppers ran up stairs and escalators and hid around the mall's cinema complex. Police found another terrified group hiding in a toilet on the first floor.

Some wounded were wheeled out on stretchers and shopping trolleys. Other walked out, some with bloodied clothing wrapped around wounds. Dozens of wounded were ferried away by ambulance.

Police cordoned off the roads surrounding the mall in central Nairobi's Westlands neighborhood.

"I personally touched the eyes of four people and they were dead. One of them was a child," said one former British soldier at the scene. "It's carnage up there."

(Additional reporting by James Macharia, Humphrey Malalo, Njuwa Maina and Goran Tomasevic in Nairobi, Dan Williams in Jerusalem, Kevin Liffey and Michael Holden in London, Guy Kerivel in Paris and Lesley Wroughton and Paul Eckert in Washington; Writing by Richard Lough; Editing by Kevin Liffey)