The ANC, which lost its parliamentary majority in a May election, has agreed to enter into a government of national unity with other parties.
Cyril Ramaphosa has been re-elected for a second five-year term as president of South Africa.
The result comes after his African National Congress (ANC) party struck a late coalition deal with the centre-right Democratic Alliance (DA), a former political foe, and smaller parties.
The ANC lost its controlling majority in last month’s election after ruling for 30 years since the end of apartheid.
It won just 40% of the vote, forcing Nelson Mandela’s legacy liberation movement to negotiate a power-sharing agreement with rival parties.
In a speech to parliament, Mr Ramaphosa, 71, praised the parties for coming together.
He said he was “humbled and honoured” to be elected again as president, which was a “big responsibility”.
“This is what we shall do and this is what I am committed to achieve as the president,” he added.
The deal marks the start of a new era in South African politics.
Following two weeks of intensive talks with opposition parties, Sihle Zikalala, a member of the ANC’s governing body, said in a post on X on Friday: “Today marks the beginning of a new era where we put our differences aside and unite for the betterment of all South Africans.”
John Steenhuisen, leader of the DA, said he was looking forward to working on “serving the people of the country and building a better future”.
“I think we get an opportunity today to write a new chapter for South Africa and that chapter I think we can make the best chapter ever. No party has got a majority. We are required to work together and we’re going to do it,” he added.