President Mokgweetsi Masisi’s party fends off surprising challenge from former ally to secure another term in office.

The ruling Botswana Democratic Party (BDP) has won the general election after securing 29 national assembly seats, representing 51 percent of the vote, the chief justice announced on Friday.

Botswana voted on Wednesday to elect 57 national assembly and 490 local government representatives, with the candidate of the winning party set to become president.

The main opposition, the Umbrella for Democratic Change (UDC), secured 13 seats while the Botswana Patriotic Front won three and the Alliance for Progressive only one, with 73 percent of the voting districts counted so far.

The BDP will now have to move swiftly to transform the economy. Since independence from Britain in 1966, the Botswana economy has grown at 8 percent a year to become one of Africa‘s most successful, but it is now at risk of coming unstuck because of over-reliance on a single commodity – diamonds.

“Although vote counting is still ongoing, the numbers of parliament seats attained so far by the BDP obliges me to declare Mokgweetsi Masisi as the elected president of Botswana,” said Chief Justice Terrence Rannowane.

President Masisi campaigned on his record on tackling corruption, such as making a declaration of assets obligatory for public sector officials. He has also overseen a sharp reduction in bureaucracy for small businesses.

“We are going to … tackle the challenges the country is facing … improving the value chain of our national products, whether it’s in tourism or minerals,” Masisi said after voting on Wednesday in his home village of Moshupa.

“This will help us achieve our goal of migrating towards a high-income country.”

Observers said Wednesday’s election went smoothly in one of Africa’s most stable countries. Turnout was not immediately clear.

But the UDC, which posed the first and greatest challenge so far to BDP dominance, claimed the process was flawed, labelling the vote “not fair”.

Former allies split

Masisi, 58, had been presented with a surprising challenge after former President Ian Khama broke away and announced his support for the opposition coalition UDC.

Khama stormed out of the BDP in May after accusing Masisi – his deputy until last year – of autocracy.

Khama hand-picked Masisi as his successor when he stepped down last year following two terms in office in the diamond-rich country. But Masisi moved away from some of Khama’s policies, including by loosening restrictions on elephant hunting to appeal to rural voters.

Many had wondered whether the ruling party would be toppled for the first time since independence in 1966.

Some in Botswana thought the election would hinge on whether people supported Khama’s rejection of his own party, and some criticised the former president of trying to extend his influence.

About 931,000 of the country’s 2.2 million people registered to vote in the parliamentary and local elections.