DAR ES SALAAM, Tanzania — The governing party, which has reigned for decades, is determined to extend its monopoly on power. The opposition is convinced it has the numbers to take over. The population is growing at an explosive rate, with millions mired in poverty. Gangs of young men from rival parties have already clashed in an uncharacteristic burst of political violence.

On Sunday, Tanzania, usually one of Africa’s most peaceful nations, a country of stunning game parks and a storied history along its Indian Ocean coast, faces its gravest political test: the most heavily contested and unpredictable presidential election in the nation’s 50-plus years. Most observers, including leading officials, say it is too close to call, which makes people nervous. Many expatriates and others with wealth have jetted off, choosing these weeks as the right time to take an impromptu family vacation.

The backdrop is a continent whose relationship with democracy has become ambivalent, at best. Tunisia held its first democratic presidential vote last year, while in Nigeria something remarkable happened: The president freely admitted defeat in elections and handed over power to a rival from another party, the first such transfer since the return of democratic rule there.

But elsewhere on the continent, more and more leaders seem to be rolling back the democratic spirit. From Burundi to Burkina Faso, several presidents have recently pushed to abolish term limits, with varying degrees of success — and chaos.