NAIROBI, Kenya — The ferocious armed political movement known as the Shabab is on the ropes in Somalia, losing territory and influence in its home country.

Yet this weekend, the Shabab showed it is as dangerous as ever as a terrorist force, keeping Kenyan forces at bay through two days at the Westgate mall in Nairobi even as the militants mounted a coordinated attack against African Union forces in Mogadishu, according to senior American counterterrorism and diplomatic officials.

Some officials warned that the Shabab could be signaling a wider offensive, particularly within Kenya, despite its losses in recent years at the hands of the African Union and Kenyan troops in Somalia, its home country.

“What we’re witnessing is Al Shabab taking its asymmetric attacks into Kenya at the same time it’s intensifying its pattern of attacks in Somalia,” said one senior American official who has been monitoring classified intelligence reports and diplomatic cables since the attack started Saturday.