JOHANNESBURG (Reuters) - At least four South African political parties agreed on Friday to work together in a new government, but many questions remained about how they will divvy up key jobs and reconcile opposing policy positions.

The African National Congress (ANC) lost its majority in a May election for the first time since the end of apartheid 30 years ago, forcing it to form an alliance to continue governing and pitching South Africa into uncharted political territory.

The ANC's biggest rival, the Democratic Alliance (DA), has signed on to the deal, while the smaller Inkatha Freedom Party (IFP) and the Patriotic Alliance (PA) have said they will join.

President Cyril Ramaphosa will lead the government since his ANC remains the largest party, DA leader John Steenhuisen said. An ANC member was elected parliament speaker, and a DA source told Reuters that the DA would get the role of deputy speaker.

But only phase one of negotiations is complete, Steenhuisen told journalists. The next phase will seek to develop a policy agenda, he said.

"This is not the end of the process, and the road ahead will not be an easy one," he said.

After the president is elected on Friday he is expected to be inaugurated within five days. A cabinet is usually formed within days of that.

"Things are fluid," ANC Secretary General Fikile Mbalula said on Friday, adding that cabinet positions had not been decided yet.

Steenhuisen said the DA would assume leadership roles in cabinet and on parliamentary portfolio committees broadly in proportion to its share of seats in the National Assembly.

A statement of intent for the unity government seen by Reuters also said the government would be constituted "broadly taking into account the number of seats parties have".

Nationally, the ANC won about 40% of votes and the DA won about 22%. The IFP won almost 4% and the PA 2%.

Constitutional law scholar Pierre de Vos said the most surprising part of the statement was a clause saying decisions must be taken by sufficient consensus, defined as agreement by parties in the alliance representing 60% of parliamentary seats.

"(This) makes it impossible for DA or ANC to push through policies against (the) will of the other party," he wrote on X. "It means cabinet decisions require both ANC and DA to agree."

"The major sticking points were the concept of proportionality and the concept of sufficient consensus," DA negotiator Helen Zille said. "We didn't want to be in a situation where we were merely propping up an ANC government."

(Additional reporting by Wendell Roelf in Cape Town; Editing by Andrew Heavens)

By Nellie Peyton