This week's presidential election re-run in Kenya has implications not only for the country but also for much of the continent, says the BBC's new Africa editor, Fergal Keane.
The last days have passed in a swirl of chanting crowds, arguments in the courts, and meetings between powerful politicians and election commissioners. The tension ahead of the polls crackles like static on the streets of Nairobi.
At the Githurai junction on the city's outskirts, several thousand people gathered to cheer President Uhuru Kenyatta.
Passing cars were surrounded and plastered with party stickers. Briefly enmity flared. A man leaned out of a passing coach and drew his finger across his throat, shouting abuse at the President's supporters. They surged forward but bus and man were quickly gone.
The days tremble with rumours. The election may happen. Or it may not. The Independent Election Boundaries Commission has warned it can't guarantee a credible poll in the prevailing circumstances.
Old friends I have spoken with express alarm at the rise in ethnic antagonism. International diplomats seem in a quandary - fearful of election day violence while acknowledging that the fresh poll was ordered by the country's highest court.
When I first reported from Africa, back in the Cold War days of the 1980s, there were only very occasional elections, usually resulting in the return of the incumbent with 90% or more of the vote.
So when Kenya had its first democratic election in 1992, it was easy to be carried along by enthusiasm for the new age. After all, President Daniel arap Moi had been in power for 14 years, during which time there had been a long spree of looting of state assets, worth billions, by an entrenched elite connected to the ruling party.
Political enemies were locked up and worse. But Moi was elected - twice. He knew how to manipulate tribal rivalries to his advantage - and his party machine had very deep pockets. Still there was now at least the possibility of democratic change.
Across Africa it seemed as if a new order of accountability was coming. The great kleptocrat Mobutu Sese Seko had been swept from power in the Democratic Republic of Congo. The apartheid state in South Africa was transformed into a multi-racial democracy.
I had met Mobutu and Moi and the leaders of the apartheid regime in South Africa and witnessed the brutality and bribery through which power was maintained in much of the continent. I had also listened to diplomats, among them representatives of Her Majesty's government, tell me that President Moi at least guaranteed stability in Kenya. He kept the tribes from tearing each other asunder.
The French would have told you the same thing about any of the despots they supported in Francophone Africa. It was an attitude of mind rooted in deeply patronising attitudes towards Africans, and it ignored the role of foreign interests in creating much of the mess.
But Africans were hungry for change. The Cold War had ended and with it the sorry history of support for despotic regimes by both the West and the Soviet bloc. Some of the new leaders came to power through war, but in those heady days of the late 1990s all the talk was of democratising.
The most remarkable movement in the continent's post-colonial history was not led by warlords or tribal chiefs but by a generation of Africans who believed their destiny would be shaped by their own actions. From Accra to Johannesburg to Nairobi, and thousands of points in-between, civil society began to mobilise.
I watched the Kenyan campaigner John Githongo forensically detail the corruption of the ruling elite and publish his results. In the remote Congolese village of Kachanga I met a women's association treating victims of mass rape and gathering evidence against the perpetrators.
The idealistic and energetic also mobilised around issues like the environment, economy, health and free media. The pace and dynamics of change were dictated by the internal realities of each state. But an overarching theme became apparent - the one-party state was becoming the exception.
The essential change was psychological. Young Africans saw themselves becoming agents of change much as their forebears had done in the years around, and just after, the end of colonialism. Two decades ago I could not have imagined the recent peaceful elections in Liberia, a state written off as irredeemably "failed".
But in a large swathe of the continent - central, eastern and much of southern Africa - I underestimated how efficiently the elites would take control of the machinery of modern democracy.
In different places they used different tactics - some buying up media outlets to promote their cause, others bribing enemies so that they became friends or manipulating ethnic antagonism into a weapon to be used on the campaign trail, and still more changing the law to extend presidential terms or silence outspoken opponents.
Some members of the new governments merely continued the corrupt practices of the old, siphoning off millions as the moribund economies of one-party states made the transition to a free market.
In South Africa it gave rise to a new class - the so called "tenderpreneurs" - whose connections to the powerful guaranteed lucrative government contracts.
Across much of this region - from the Democratic Republic of Congo, to Uganda, Rwanda, Eritrea and others - authoritarianism is on the rise. Elections are postponed, independent media are silenced, presidential term limits are expanded and opposition figures locked up.
It is in this regional context that Kenya's Chief Justice, David Maraga, emerges for many - if not for President Kenyatta's supporters - as a man of great courage.
The Supreme Court's decision to annul the elections because of irregularities in the electoral process, told the world that this Kenyan court would not accept a second-class democracy. Across Africa there was a sense of pride in this singular decision. Maraga was seen as speaking for the many who still stand for and demand accountable rulers and an independent civil service.
Since the Supreme Court decision tension has steadily risen. Elections are set for Thursday, but the opposition leader Raila Odinga refuses to take part.
It is possible to simultaneously take heart from the courage of the chief justice and the changed Africa he represents, and to be deeply worried about the escalating tension gripping the country in the wake of the court's decision.
For Kenyans know that political violence often goes unpunished, particularly when the instigators are powerful people. So, often, does brazen corruption. The long struggle is not between political elites at the polling booth. It is a fight waged by a still resourceful civil society, independent judges and honest political campaigners to demand accountability.
The conduct of these elections and what happens in their aftermath matters hugely to Kenyans, millions of other Africans and the broader international community. An unstable Kenya has serious implications for the fight against terrorism in Somalia and, potentially, for the aid operations in South Sudan.
A peaceful resolution to this democratic crisis would be an example to the continent. Mr Githongo told me that "democracy is entering a dark tunnel but there might just be light at the other side".
The struggle to protect the gains made by honest men and women across this region is entering a critical phase.