A regional economic powerhouse and a popular tourist draw, Kenya has not suffered a high-profile jihadist attack since 2019, when 21 people lost their lives at a hotel and surrounding offices in Nairobi.
The recent attacks have been small-scale and focused on minor targets, but have raised fears that Al-Shabaab jihadists, who have been blamed for the assaults, are turning their attention to Kenya as they suffer losses in their native Somalia.
Estimated to have between 7,000 and 12,000 fighters, Al-Shabaab has in recent months faced a multi-pronged counterterrorism offensive by the Somali National Army and US-trained "lightning" commandos supported by clan militias known as "macawisley".
The militants, who have waged war against the fragile government in Mogadishu for over 15 years, have recently carried out several attacks along Kenya's long and porous frontier with Somalia.
Twenty-four people, including 15 security officers, were killed in six separate attacks last month alone.
In one of the most grisly assaults claimed by the group, about 30 militants descended on two sparsely-populated villages in Kenya's coastal Lamu county on June 24 and killed five civilians, beheading some of them.
One resident, Hassan Abdul, said that "women were locked in the houses and the men ordered out, where they were tied with ropes and butchered".
The remote forested mainland is not normally a stopover for tourists visiting the nearby popular Indian Ocean island of Lamu, but the gruesome killings are a signal to Kenya, analysts say.
The attacks are a way for "Al-Shabaab to say that despite being under pressure, they still have the firepower and are a force to be reckoned with," said Nicolas Delaunay, International Crisis Group director for East and Southern Africa.
"It could also be a way of warning Kenya who has pledged to participate in the Somali government's offensive against the Al-Shabaab," he told AFP.
Risk of regional spillover
Kenya is no stranger to the long-running Islamist insurgency in Somalia and has been repeatedly targeted by Al-Shabaab since it sent troops into the country in 2011 as part of an African Union force.
The militants appear to have been emboldened by the changes in Kenya's security leadership following the election of President William Ruto last August, said Roland Marchal, an Africa specialist at Sciences Po university in Paris.
"There is relative disorganisation at the border," Marchal said, adding that Al-Shabaab was seizing the chance to take "revenge" against Kenya for deploying troops in rural central and southern Somalia where the militants remain entrenched.
The violence has also threatened to spill into Ethiopia, as the militants try to make their presence felt in Africa's second most populous country.
Addis Ababa said last month that it had foiled an attack by the jihadists in the border town of Dollo.
Al-Shabaab fighters were chased out of Mogadishu in 2011 by an African Union mission which has been in Somalia since 2007.
The militants have also lost some ground in the countryside after Somalia's President Hassan Sheikh Mohamud last year launched an "all-out war" against the group, describing the jihadists as "bedbugs".
But while the gains of the Somali offensive have been significant, the "situation still remains very fragile," African Union Commission chair Moussa Faki Mahamat warned last weekend.
Hassan Khannenje, director of The Horn International Institute for Strategic Studies in Nairobi, told AFP that Al-Shabaab was "on the back foot in Somalia".
"There is a desire on their part to demonstrate continued relevance and resilience."
'Manifestation of desperation'
A US official last month told AFP the recent cross-border attacks by Al-Shabaab were a "manifestation of desperation".
But Kenya is taking no chances.
A string of major attacks on the Westgate shopping centre in 2013, Garissa University two years later, and the Dusit hotel complex in 2019 left hundreds of Kenyans and foreigners dead.
The East African nation earlier this month said it was delaying the planned reopening of its long-closed border with Somalia over the deadly attacks.
The phased reopening would not go ahead as announced "until we conclusively deal with the recent spate of terror attacks and cross-border crime," Interior Minister Kithure Kindiki said.
Analyst Khannenje said the wave of attacks "should serve as a warning" to Kenya.
"Vigilance is key."