Nic Cheeseman is a professor of democracy at the University of Birmingham.

The Kenyan presidential election, scheduled for Aug. 8, is on a knife-edge. Early polls in January gave President Uhuru Kenyatta a commanding lead over his main rival, Raila Odinga, but the gap has been narrowing. While one poll released in July gave the president a four-point lead, another put Odinga ahead for the first time. As we head into the home stretch, many feel it is too close to call.

The closer the race has become, the more leaders, journalists and ordinary Kenyans have started to worry that the losing side will reject the results, increasing the risk of post-election violence. The flawed 2007 elections led to widespread ethnic clashes in which more than 1,000 people lost their lives and 800,000 were displaced. The recent murder of a senior electoral commission official, combined with opposition allegations that a plan is afoot for the military to rig the election, has done nothing to lower the political temperature.

Elections in Kenya are destabilizing because both sides are strong enough to win, and both feature factions that are not prepared to lose. The consequence has been a series of unpredictable contests that represent great moments of national stress. Once the polls close and counting begins, many of those who love the country will be holding their breath.

Kenya is not alone. Instead, it belongs to a group of African states in which weak democratic norms go hand in hand with intense political competition. This combination almost inevitably leads to election controversy and unrest. It is the same context that led to intense brutality in 2008 in Zimbabwe as the ruling party used force to keep President Robert Mugabe in power after he had effectively been beaten by opposition leader Morgan Tsvangirai. And it is the same combination that resulted in heated controversy in Zambia in 2016, when the opposition claimed that it had defeated the ruling party, only to be declared the loser by a wafer-thin margin amid alleged irregularities.

These states are distinctive in combining an elevated level of competition with weak electoral systems. Although the continent is known for dominant-party states — such as Rwanda, where President Paul Kagame regularly wins more than 90 percent of the vote — it also features a number of extremely vulnerable ruling parties. In stark contrast with the dictatorships of the Middle East, or Vladimir Putin’s stage-managed political theater in Russia, opposition parties in places such as Kenya regularly win more than 40 percent of the vote. There are few other places in the world in which democracy is so young and fragile, and where opposition leaders do so well, so regularly.

The closeness of many African elections generates challenges. In order to get over the line, leaders often tell their supporters that they are on course for victory. This means that, whoever loses, a significant proportion of the electorate feels cheated. Combined with the frequency of electoral fraud and the use of election gangs, this generates a heady cocktail that can trigger political unrest.

In the Kenyan context, the 2017 election involves particularly high stakes because they represent long-time opposition candidate Odinga’s last chance at the presidency. Having narrowly lost out in 2007 and 2013 — when he believes that he was the victim of fraud — he is coming toward the end of his political career. He is 72, and his supporters know that it is unlikely that he will contest many more elections. As a result, some have taken to saying that they “must” win this time around in order to allow Odinga to achieve his greatest ambition and take the presidency.

For its part, Kenyatta’s Jubilee Party is also desperate to retain power in order to maintain political and economic control — and the contracts and corruption opportunities that go with it. For many members of Kenyatta’s entourage, such as Deputy President William Ruto, winning power is also key to their future political ambitions. Ruto plans to run for the presidency himself in 2022 but knows that his campaign is far more likely to be successful if it has state backing.

However, while both sides are desperate to win and the electoral process looks shaky, the election is unlikely to see a return to the clashes of 2007-2008. Neither political leaders nor Kenyans themselves want to a return to ethnic conflict. Moreover, a record 180,000 security personnel will be deployed to strategic “hot spots” around the polls to deter unrest — almost double the number last time around. Thus, while frustration, anger and localized protests are likely, widespread political instability is not.

Much depends, though, on the quality of the process itself. As in 2013, Kenya this time is relying heavily on election technology to prevent rigging and confer credibility on the electoral system. However, opposition leaders worry that the government is planning to subvert the technology. Most notably, they allege that the election commission’s acting director of information and communications technology, Chris Msando — whose tortured body was found late last month, just days after he had been reported missing — was killed because he was dedicated to making the new systems work. Against this backdrop, if the outcome is controversial and the technology fails — as it has done before — the losing party is unlikely to be willing to accept the results.