CAPE TOWN — It was like a scene from the apartheid days: a military unit with armored trucks and assault rifles patrolling the streets of a South African township.

But as soldiers arrived in Mitchells Plain, an impoverished suburb outside Cape Town, people did not hide inside or erupt in protest, as many would have decades ago when the army was a symbol of white minority rule.

Instead, residents rushed from their homes to welcome the troops, who were sent in last month to quell an extraordinarily bloody spate of gang violence and have remained in the area ever since.