A ghostly coat of ash coated the shelves of a supermarket. Dozens of cars were scorched. Melted plastic dripped down like taffy. It took heavily armed Kenyan security forces more than three days to dislodge the last of the militants, then an intense fire burned in the supermarket for days.

The initial attack was carefully planned and well rehearsed, officials say, with the building’s blueprints studied down to the ventilation ducts. The team of attackers slipped undetected through Kenya’s porous borders, often patrolled by underpaid — and often corrupt — border guards. A day or two before the Sept. 21 attack, powerful belt-fed machine guns were secretly stashed in a shop in the mall with the help of a colluding employee, officials say.

Western security officials say they believe that several fighters slipped out of the mall during the attack, dropping their guns, changing clothes and blending in with fleeing civilians, an account echoed by some witnesses. The authorities in Kenya, widely perceived as an oasis of peace and prosperity in a troubled region, are struggling to explain how a handful of Islamist extremists could lay siege to a shopping mall, then hold off security forces for days.