When Kenya sent troops to Somalia in 2011 to fight Islamic extremists, the al-Qaida-linked group al-Shabab threatened to retaliate by bringing down Nairobi's skyscrapers.

The buildings still stand, but a series of mass killings in which non-Muslims were singled out for slaughter has increased pressure on Kenya to improve security along a porous border and explain why its army should remain in Somalia.

Al-Shabab quickly claimed responsibility for the latest chilling assault: Gunmen invaded a quarry in northern Kenya, lined up 36 non-Muslim laborers, and killed them early Tuesday. That followed a similar massacre on Nov. 22, when al-Shabab killed 28 Kenyans on a bus, again sparing the Muslims among the passengers.

The group's most notorious attack was on the Westgate shopping mall in Nairobi last year, when it also targeted non-Muslims, although the four gunmen killed people of all faiths. At least 67 died in that siege in the capital of the East African nation.

Kenya sent its military forces into Somalia in hopes of creating a secure buffer zone between Somalia's internal chaos and Kenyan territory. But the series of attacks by al-Shabab has left Kenyans demanding change, and President Uhuru Kenyatta responded Tuesday by shaking up the leadership of his security team.

"We went into Somalia without a clear plan. If we had a plan, we would have anticipated the blowback and ensure our borders are secured," said Abdullahi Boru, an independent East Africa security analyst who formerly worked for the International Crisis Group. "We are terrible at this job (of internal security) ... and al-Shabab knows our weak points."

Among those weak points, Boru said, is endemic corruption "across all government agencies" in Kenya, a point that security analysts and citizens agree on.

Allegations that al-Shabab fighters bribed police to let them cross the Somalia-Kenya border are common. But because the border is so long and unguarded, that's not even necessary.

Al-Shabab once controlled most of Somalia's capital, but has steadily been losing territory to the African Union forces. That makes the group more likely to hit back elsewhere, and Kenya's ethnic and political disunity and its ill-equipped security forces make it an easy target, said Sarah Tzinieris, an analyst at Maplecroft, a risk assessment firm.

The border area will remain susceptible to al-Shabab attacks due to its remoteness and inadequate security patrols, Tzinieris said. "Soft targets" like the Westgate Mall also remain vulnerable, she said.

Kenya has carried out numerous "counterterrorism" operations in Nairobi and Mombasa, often against Muslim populations or at mosques. Those actions have raised Muslim-Christian tensions — a situation that Tzinieris says increases the likelihood of homegrown attacks from al-Shabab sympathizers.

Besides creating fear among non-Muslim residents of northern Kenya who are demanding that authorities ensure their safety, the killings have opened up Kenyatta's government to criticism.

The political opposition group CORD called Tuesday's attack "another senseless slaughter." It blamed "corruption within our security, political, intelligence and military leadership."

For months, CORD has been calling for an overhaul of the country's security apparatus. Kenyatta on Tuesday finally fired the interior minister, who was ridiculed for a slow response to the Westgate Mall attack, and accepted the resignation of the police chief.

Although some in Kenya advocate withdrawing its troops from Somalia, Kenyatta said that was not his plan.

"We shall continue to inflict painful casualties on these terrorists until we secure our country and region. Our stability and prosperity depends on a secure neighborhood," he said.

Boru, the security analyst, said the country lacks a long-term strategy in Somalia.

"We need to set out a clear window on when we are leaving," Boru said. "The window between when Kenya being considered liberators and that of being regarded as invaders has closed."

Boniface Mwangi, one of the country's most vocal activists, criticized Kenyatta for replacing Interior Minister Joseph Ole Lenku with another man from Kenya's Maasai community, Joseph Nkaissery, a retired military major general.

Mwangi posted on Twitter the results of a government Truth, Justice and Reconciliation report that recommended Nkaissery be investigated for human rights abuses during his military service.

"The fish rots from the head," he said. "When the president makes an appointment thinking about his political survival and overlooking merit, then there is the problem."

He said Kenya's "ruling elite is out of touch with reality."

"They have motorcades and bodyguards, and they are telling us that security is our responsibility. That's telling us that we all should be vigilantes," Mwangi said.