South Africa parliament must elect a President on Friday . Photo: Others 

South Africa's Parliament is due to elect a president on Friday, and major political parties are still working out the last details of a coalition agreement that might or might not see Cyril Ramaphosa return for a second term as leader of Africa's most industrialised economy.

It appears likely to go to the wire after Ramaphosa's African National Congress party said it would hold a meeting of its most senior officials in Cape Town on Thursday night, barely 12 hours before Parliament convenes in the city and begins the process of choosing the president.

South Africa has been in a political deadlock since the ANC lost its 30-year majority in an election two weeks ago, forcing it to approach other parties for some kind of agreement to co-govern for the first time.

The first priority for the ANC is reelecting Ramaphosa, but it will need help from other lawmakers because it no longer has a parliamentary majority.

No final agreement between parties has been announced, and the ANC's own internal leadership also has to formally approve any coalition.

Here's what we know about the country's most important political negotiations in three decades.

How the president is elected

Ramaphosa, 71, could still get a smooth ride to a second term if he is the only candidate nominated in Parliament on Friday; he would then be automatically reelected. But if another candidate or candidates are nominated, a vote follows, and the ANC would need its coalition partners to secure Ramaphosa's reelection.

First piece of puzzle

The Inkatha Freedom Party announced Wednesday night that it would join the ANC's proposed "government of national unity," the first piece of the coalition puzzle. It backed Ramaphosa for a second term. But the IFP only holds 17 seats in the 400-seat lower house of Parliament that elects the president, and the ANC needs others to get to the critical point where they have a joint majority.

The key piece

The main opposition Democratic Alliance now holds the key with its 87 seats, the second-highest number behind the ANC's 159.

The DA has not confirmed that it has joined the unity government, although it has previously said it is willing.

It says it just needs to work out the details with the ANC. That is the crucial negotiation, and those talks were expected to continue on Thursday. An ANC-DA-IFP agreement appears to be the core of any coalition now.

However, the DA has been the most critical voice of the ANC over the last 20 years, and bringing the two parties together to co-govern is complicated.

There is also some resistance within the ANC to forming an agreement with a party that it has viewed as its number one political foe for so long.

Opposition to the coalition

Two other major parties, the new MK Party of former President Jacob Zuma and the far-left Economic Freedom Fighters, have said they will not join a unity government.

MK also tried to get the Parliament sitting halted in court but lost its case. MK says its 58 new lawmakers will boycott Friday's first sitting of the new Parliament, but that shouldn't affect any vote for president.

South Africa's constitution says at least one-third of Parliament's 400 lawmakers need to be present to attain a quorum and for votes to go ahead. The ANC holds more than one third of the seats on its own.

What will happen?

The chief justice will oversee the first part of the parliamentary session, when lawmakers are sworn in before electing the speaker and deputy speaker. Then comes the vote for president.

There are 18 political parties represented in South Africa's Parliament for this five-year term, from the ANC with 159 seats down to the Pan Africanist Congress of Azania, the GOOD party, and the United African Transformation Party with one seat each.

Click here to follow our WhatsApp channel for more stories.

AP