Over 30 years, he forged a maze of security agencies and militias to bind his often ruthless rule. But he was undone in a middle class revolt over the economy.