The heavily armed men roused the sleeping quarry workers in the dead of night.

As in previous such attacks, the gunmen singled out the non-Muslims by asking them to recite the Islamic creed. Then they killed 36 of them — most with a gunshot to the back of the head, according to a survivor who hid nearby during the slaughter.

The Islamic militant group al-Shabab claimed responsibility for the methodical massacre in northern Kenya early Tuesday — 10 days after a similar attack on a bus that killed 28 — and it prompted President Uhuru Kenyatta to shake up his national security team amid public outrage over the continuing violence.

"I know we are all under a lot of pressure, but I appeal to each one of us: This is not a time to be cowed by the enemy," Kenyatta said in a nationally televised address.

"This is a war we must win," he said. "We will not flinch or relent in the war against terrorism in our country and our region."

Al-Shabab has been fighting for years to establish hard-line Islamic rule in neighboring Somalia. The al-Qaida-linked group has vowed to strike against Kenya for sending its troops into Somalia, and it has claimed it was behind the bus attack and the siege at the Westgate shopping mall in Nairobi last year that left 67 dead.

The group has suffered a series of setbacks this year. It lost control of a key coastal stronghold in Somalia to government and African Union troops in October, and its spiritual leader, Ahmed Abdi Godane, was killed in a U.S. airstrike Sept. 1.

But the Nov. 22 bus attack and the quarry killings Tuesday showed that the group is still capable of bold incursions into the east African country.

Al-Shabab spokesman Sheikh Ali Mohamud Rage said the quarry attack was a response to Kenya's deployment of troops to Somalia in 2011 and to alleged atrocities committed by the Kenyan army there. Al-Shabab said a recent airstrike had killed innocent people and destroyed their property.

In his security shakeup, Kenyatta fired Interior Minister Joseph Ole Lenku, a former hotelier whose competence had been questioned, and replaced him with Joseph Nkaissery, an opposition politician and retired army general. Kenyatta also accepted the resignation of Police Chief David Kimaiyo, who said he was taking early retirement for personal reasons.

Tuesday's attack began after 12:30 a.m. when about 50 men walked into the tented camp next to the quarry in the Koromey area on the outskirts of the town of Mandera, said worker Peter Nderitu.

When he heard the shooting, Nderitu ran and hid in a trench. He said he heard his colleagues being asked to recite the Shahada, an Islamic creed declaring oneness with God. Gunshots followed.

He only rose from his hiding place two hours later, when he was sure there was no more movement. The bodies of his colleagues were in two rows and nearly all had been shot in the back of the head, he said. The gunmen escaped.

The bodies of the 36 were flown to Nairobi, where relatives gathered at the city morgue to identify their kin.

U.S. State Department spokeswoman Marie Harf said Washington vigorously condemned al-Shabab's "continued cowardly, brutal targeting of civilians."

Public pressure has been mounting on Kenyatta to replace the two security officials. In his speech, he said the Kenyan military incursion in Somalia has been largely a success, putting a depleting al-Shabab in retreat, although he noted it remains a threat.

"The obvious intent is to create hostility and suspicion across ethnic and religious lines and to drive non-Muslims from certain parts of this country. The ultimate aim of this atrocious campaign is to establish an extremist caliphate in our region," he said.

Kenyatta was criticized after the bus attack for not cutting short a four-day official trip to Abu Dhabi. Public anger increased after photos emerged on social media appearing to show Kenyatta at a social event, as well as media reports that he attended the Formula 1 Grand Prix that weekend in the United Arab Emirates instead of addressing the security crisis at home.

Kenyans in the northeast have been on edge. After last month's bus attack, about 100 non-Muslims sought refuge at the Mandera army base, demanding that the government evacuate them.

Kenyatta's chief of staff, Joseph Kinyua, tried to persuade non-Muslims to stay in Mandera County, whose population is predominantly Kenyan Muslims of Somali origin.

Billow Kerrow, a senator from the area, said the militants "want to create chaos in the country by creating divisions between Muslims and Christians."

"I am worried that this may get out of hand. They can be so emboldened because they are meeting no resistance and decide to take over a town," Kerrow said.

Despite the central government's claims that it has increased the police and army presence in the county, he said there is a lack of coordination and commitment on dealing with the insecurity in Mandera.

___

Associated Press writer Abdi Guled contributed to this report from Mogadishu, Somalia. AP video producer Josphat Kasire contributed to this report from Nairobi.