Mr. Buhari stood as ramrod straight as he had in the days when he rose in a coup against Nigeria’s fledgling, but corrupt, democracy. After taking power, he soon instituted what he called his attempt to straighten out a chaotic nation.

That tarnished past has been, if not forgotten, at least pushed aside by many in the tumultuous jumble of Nigerian history. Mr. Buhari is expected to do particularly well in the Muslim north, his home turf, on Election Day, as he did in an unsuccessful run four years ago.

Still, his campaign faces stiff obstacles. Tens of thousands of people in northern Nigeria have been displaced by relentless violence, and many of them will be unable to vote in the Feb. 14 election. Even if they can, Nigerian elections are prone to violence and fraud.

This week, the streets of Kaduna were packed three-deep with people, many waiting since early morning or trekking miles from nearby villages to see him. Partisans yelled as they climbed on the general’s vehicles, frenetically brushing windshields with the symbolic brooms.

Mr. Buhari spoke only briefly to the packed stands in a downtown stadium, vaguely promising greater security, prosperity and better education. But the words appeared not to be the point. It was his presence, and an implicit promise of austerity and military action, that the crowd seemed to want, after years of scandalous stories in the Nigerian news media about missing oil funds and high living by officials in Mr. Jonathan’s administration.

“The enthusiasm for Buhari is almost like a religion,” said Nasir el-Rufai, a former government minister running for governor of Kaduna State.

“Look at all these people,” he said, pointing at the crowds pressing up against his own car before the general arrived. “They are all waiting just to see Buhari.”