Pro-Ouattara fighters of the FRCI prepare for the ‘final assault' at the Golf Hotel in Abidjan on 5 April. Photograph: Str/AFP/Getty Images

The Republican forces loyal to Alassane Ouattara, the internationally recognised winner of Ivory Coast's election last November, are, as I write, in the final stages of a violent showdown in the capital, Abidjan, to oust the recalcitrant losing president, Laurent Gbagbo. This is proving to be a bloody last stand as the former history professor, Gbagbo, seems to have ignored the lessons of the past. In 1990 the Liberian autocrat Samuel Doe was captured by rebels in Monrovia and tortured to death; a year later the Somali strongman Siad Barre fled into exile as a rebellion approached Mogadishu; the Zairean despot Mobutu Sese Seko also fled his capital in 1996 as rebels approached.

The seeds of the Ivorian crisis were sown during the autocratic rule of Félix Houphouet-Boigny between 1960 and 1993. Though he adopted an enlightened policy towards the large immigrant population, the economy declined from the 1980s even as he built the world's largest church – the "basilica in the bush" – in his home town of Yamoussoukro. Houphouet's heirs – Henri Konan Bédié, General Robert Guei, and Gbagbo – instituted a xenophobic policy of "Ivoirité" which discriminated against Ivorians of mixed parentage, and led to the exclusion of Ouattara – a former prime minister – from the presidential elections of 1995 and 2000. The consequent alienation of Ouattara's northern Muslim constituents was exacerbated by Gbagbo's dismissal of 200 mostly northern soldiers from the army. These tensions culminated in a coup attempt in 2002 by largely northern officers, and the emergence of the Forces Nouvelles, the Republican Forces' forerunner.

France, which had maintained a military base in Ivory Coast since 1960, sent in 4,600 troops to monitor a ceasefire, and financed the deployment of some 1,200 largely Francophone African troops. Paris – a permanent member of the UN security council – then played a key role in the deployment of what is now a 9,000-strong UN peacekeeping mission, reducing its own force to 900. For six years the peacekeepers kept government and rebel troops apart – until last year's crisis. France, the country that Gbagbo has consistently accused of neocolonial "plots", had actually done the most to keep rebels from marching on Abidjan to topple his regime.

That Republican forces appear poised to restore Ouattara's democratic mandate stands in stark contrast to stolen elections in African countries such as Kenya (2007) and Zimbabwe (2008). Both polls resulted in messy "shotgun weddings" in which cheating incumbents – Mwai Kibaki and Robert Mugabe – remained in power. If the Republican forces succeed in their aims by using force to realise Ouattara's democratic mandate, this could have profound and ambiguous implications for future electoral processes in Africa. Ouattara will need to act as a gracious statesman in healing national divisions by bringing in some of Gbagbo's supporters and southern politicians into the government and building a genuinely integrated army.

UN peacekeepers have been rightly criticised – as they were during the Rwandan genocide in 1994, and more recently in the Democratic Republic of the Congo (DRC) and Sudan – for not doing more to protect civilians. Governments contributing peacekeeping troops are often reluctant to put their soldiers in harm's way. But with a recently reinforced peace-enforcement mandate, the UN must act decisively to protect civilians and halt human rights abuses, which have resulted in an estimated 1,300 deaths.

Both sides have been accused of committing atrocities. Gbagbo and Ouattara must thus be put on notice that they will be held accountable for war crimes committed by their fighters. The financial and travel sanctions recently imposed by the UN on Gbagbo, his Lady Macbethian wife Simone, and other associates, should also be extended to other peace "spoilers".

French troops must do more than just protect the airport in order to evacuate western nationals in yet another example of an "aristocracy of death", in which the lives of foreigners are deemed to be worth more than those of Africans. In addition, genuine suspicions persist about the stance adopted by pro-Ouattara France, whose previous self-interested interventions in Africa, and continuing support for local autocrats, cast the Gallic power in the role of a fox guarding a hen-house.

Regional actors also have an important part to play in averting a likely bloodbath in Abidjan. With reports of over 100,000 Ivorian refuges spilling into Liberia, Mali and Ghana, the negative effects of earlier civil wars in Liberia and Sierra Leone must be avoided. These resulted in 300,000 deaths and a million refugees pouring across borders. Nigeria and South Africa must use their presence on the UN security council effectively to help craft a peaceful outcome. The African Union should help to negotiate a safe exit for Gbagbo and press Ouattara to bring in his rival's supporters into any future government. Nigeria, South Africa and Angola must speak with one voice to ensure that any agreement sticks.

During this crisis, Nigeria has adopted a belligerent anti-Gbagbo stance that could still endanger the lives of its thousands of nationals in Ivory Coast. Meanwhile, Angola reportedly provided Gbagbo with funds and 300 soldiers; the Angolan tail was apparently wagging the South African dog, until Pretoria belatedly rediscovered its moral compass and recognised Ouattara's victory. Only through domestic reconciliation, regional consensus and external diplomatic and military support can a bloodbath be averted in Ivory Coast's increasingly deadly endgame.