Shehu Shagari, the former president of Nigeria who sought to revive democratic rule only to be deposed by military officers impatient with his seeming inability to confront endemic corruption and economic crisis, died on Friday in Abuja, the capital. He was 93.

Mr. Shagari died at the National Hospital after a brief illness, his grandson Bello Shagari said on Twitter.

It was a token of Nigeria’s long tug-of-war between the barracks and the ballot box that President Muhammadu Buhari — who, as an army general, removed Mr. Shagari from power in 1983 — returned to office in the 2015 elections. It was the first peaceful transfer of power between civilians of different political parties since Nigeria’s independence from Britain in 1960.

By then Mr. Shagari, patrician and mild-mannered, had become what his followers called an elder statesman as his country grappled with challenges that had become familiar: an almost reflexive recourse to graft; an economic malaise relating to falling prices of oil, Nigeria’s dominant foreign-currency earner; and a fierce divide between its northern Muslims and southern Christians that became ever more stark with the rise of a bloodthirsty jihadist movement called Boko Haram.