* Somali Islamists linked to al Qaeda claim attack
* Group wants withdrawal of Kenyan troops from Somalia
* President loses relatives in raid, vows punishment
* Volleys of gunfire, helicopters swoop low over mall
By Richard Lough and Edmund Blair
NAIROBI, Sept 22 (Reuters) - Islamist militants were holed up with hostages on Sunday at a shopping mall in Nairobi, where at least 59 people have been killed in an attack by the al Shabaab group that opposes Kenya's participation in a peacekeeping mission in neighbouring Somalia.
Brief volleys of gunfire interrupted hours of stalemate in the late afternoon. A Reuters correspondent saw security personnel on the move and as dusk closed in two helicopters swooped low over the Westgate shopping centre, which has several Israeli-owned outlets and is frequented by many foreigners.
Mobile phone signals began to fail in the area as darkness fell. Kenya's president, vowing to stand firm against Somali militants, was cautious about the outcome, saying chances of the siege ending well were "as good ... as we can hope for".
"We will punish the masterminds swiftly and painfully," he added.
Foreigners, including three Britons and two diplomats - one from Canada and another from Ghana - were killed in Saturday's attack at the upmarket mall, claimed by Somali group al Shabaab.
Shortly after the shots were fired, troops in camouflage ran crouching below a restaurant terrace along the front of the building that had been buzzing with customers when assailants charged in. One witness said they first told Muslims to leave.
For hours after the brazen attack, the dead were strewn around tables of unfinished meals. At one burger restaurant, a man and woman lay in a final embrace, before their bodies were removed. Pop music was left playing.
Scores of Kenyans gathered at a site overlooking the mall, awaiting what they expected to be a violent denouement. "They entered through blood, that's how they'll leave," said Jonathan Maungo, a private security guard.
President Uhuru Kenyatta, facing his first major security challenge since being elected in March, said he lost a nephew and his fiancée in the raid and vowed to defeat the militants.
"We have overcome terrorist attacks before," he said.
He later addressed the nation, and the world, urging wealthy governments not to warn their citizens against visiting a country heavily dependent on tourist income, while insisting that he would not pull Kenyan troops out of Somalia. He said he would "not relent on the war on terror".
As he spoke there was a new volley of gunfire inside the mall, shortly after about a dozen security personnel in camouflage moved inside the building.
Saying all the gunmen were now in one place, Kenyatta added: "With the professionals on site, I assure Kenyans that we have as good a chance to successfully neutralise the terrorists as we can hope for." Foreign governments have offered help.
The assault was the biggest single 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 coast and tried to shoot down an Israeli jet in a coordinated strike.
Al Shabaab's siege underlined its ability to cause major disruptions with relatively limited resources.
"In terms of capacity, while the group has grown considerably weaker in terms of being able to wage a conventional war, it is now ever more capable of carrying out asymmetric warfare," said Abdi Aynte, director of the Mogadishu-based Heritage Institute of Policy Studies, a regional policy and security think tank.
President Kenyatta, who said Kenya was still trying to establish conclusively who was responsible said women were among the attackers. Asked whether hostages had explosives strapped to them, he said he would not comment on operational issues.
Aynte also said the raid showed "a major failure on the part of the Kenyan security services", which had not detected an operation that must have taken several months to plan. Other experts said Western agencies had also not picked it up.
Interior Minister Joseph Ole Lenku told reporters the death toll had risen to 59, and that security forces were doing everything they could to rescue hostages still inside the mall.
He added that 175 people had been taken to hospital after an assault that could prove a costly setback for east Africa's biggest economy, which relies heavily on tourism revenues.
Kenya's deputy president, William Ruto, asked judges at the International Criminal Court in The Hague to allow him to return home to help deal with the siege and its aftermath.
He and Kenyatta face charges of crimes against humanity for their alleged role in coordinating violence that swept Kenya in the aftermath of the country's contested 2007 elections. Both deny the charges.
The dead in Saturday's assault included children, and the wounded ranged in age from 2 to 78. Many victims were at a cookery competition when assailants opened fire on them, witnesses said. More than 1,000 people were evacuated.
The focus of attention on Sunday was on the mall's branch of Nakumatt supermarket, one of Kenya's biggest chains.
Soldiers joined the security operation backed by armoured personnel carriers in the hours after the attack that was launched around 12.30 p.m. (0930 GMT) on Saturday. Security forces have been combing through the mall, clearing the floors.
As helicopters hovered over the capital, a paramilitary officer at the scene, a rifle slung over his shoulder, said: "They will be arranging how to attack (the assailants)."
An Israeli security source said that Israeli advisers were at the scene helping Kenya to work out how to end the siege.
One woman emerged on Sunday morning after hiding under a vehicle in the basement car park.
Giving her name as Cecilia, she told Reuters by telephone later that she had seen three men who looked like they were of Arab extraction judging by their skin colour.
"They were shooting from the exit ramp, shooting everywhere," she said. "I saw people being shot all around me, some with blood pouring from bad wounds. I was just praying, praying God keep me alive and that my day hadn't come."
France said two of its citizens were killed, and Canada said two Canadians died, including a 29-year-old diplomat. Ghanaian diplomat and poet, Kofi Awoonor, was also killed, as was a Chinese woman, according to China's official news agency.
U.S. Secretary of State John Kerry, who offered assistance to Kenya, said several U.S. citizens had been hurt and the wife of a U.S. diplomat working for the U.S. Agency for International Development was killed.
Al Shabaab, which is battling Kenyan and other African peacekeepers in Somalia, had repeatedly threatened attacks in Kenya if Nairobi did not pull its troops out of their country.
The group appeared to taunt the security forces, saying on its official Twitter handle @HSM_Press that there would be no negotiations whatsoever with Kenyan officials over the standoff.
"10 hours have passed and the Mujahideen are still strong inside #Westgate Mall and still holding their ground. All praise is due to Allah!", the group said late on Saturday, although its account on Twitter was suspended on Sunday morning.
Ole Lenku said the government believed that there were 10-15 attackers who security forces had been able to "isolate", but no communication had yet been established with them.
Those rescued said at least one of the assailants was a woman. One militant was shot and arrested in clashes following the initial siege, but died shortly afterwards at a hospital.
A private security firm would normally search patrons of the mall using metal detectors and open the trunks of cars entering parking areas, but guards would be unarmed. Witnesses said the attackers had AK-47 rifles and wore ammunition belts.
Kenya sent troops into Somalia in October 2011 to pursue militants it blamed for kidnapping tourists and attacking its security forces.
Al Shabaab's last big attack outside Somalia was a twin assault in nearby Uganda, targeting people watching the World Cup final on television in Kampala in 2010, killing 77 people.