Just now
Farouk Chothia,BBC News, Johannesburg
Votes are being counted after what is seen as South Africa's most closely fought elections since the African National Congress (ANC) came to power 30 years ago.
Long lines snaked outside polling stations across the country.
One electoral official in Johannesburg told the BBC the queues were reminiscent of the historic 1994 election, when black people could vote for the first time, and which saw Nelson Mandela become president.
Many people were still waiting to vote when polls officially closed at 2100 local time (1900 GMT) but the electoral commission said they would all be allowed to cast their ballots.
A record 70 parties and 11 independents were running, with South Africans voting for a new parliament and nine provincial legislatures.
Analysts say this shows that many people are disillusioned with the ANC.
"We are entering the next phase of our democracy, and it is going to be a big transition," political analyst Richard Calland told the BBC.
"We will either become a more competitive and mature democracy, or our politics will become more fractured."
The main opposition party, the Democratic Alliance (DA), has signed a pact with 10 other parties, agreeing to form a coalition government if they get enough votes to dislodge the ANC from power.
But this is highly unlikely, with the ANC expected to remain the biggest party, putting it in pole position to lead a coalition if its support does drop below 50%.
It got 57.5% of the vote in the last election compared to the DA's 21%.
South Africans do not directly vote for a president. Instead they vote for members of parliament who will then go on to elect the president.
So current President Cyril Ramaphosa is likely to remain in power.
South Africa election: Here's what voters had to say
Former President Jacob Zuma caused a major shock when he announced in December that he was abandoning the ANC to campaign for a new party, uMkhonto weSizwe (MK), which translates as Spear of the Nation.
Although he has been barred from running for parliament because of a conviction for contempt of court, his name still appeared on the ballot paper as MK leader.
The MK is expected to do especially well in Mr Zuma's home province of KwaZulu-Natal, where tensions have been high, with some incidents of violence reported during the campaign.
Police and the army have been deployed to polling stations across the country to ensure that voting takes place peacefully, and that ballot papers are not stolen.
More than 27 million people were registered to cast their ballots, with women making up 55%, according to statistics released by the electoral commission.
In terms of age group, voter registration was highest among those who are 30 to 39 years old. They make up almost seven million of the 26.7 million voters.
The youth could sway this election in their favour.
Artist Njabulo Hlophe, 28, said young people in South Africa tend to get marginalised but, "this is as much our country as our parents... they're leaving it to us, so someone that really cares about the young people is someone I’m really looking at".
Support for the ANC is expected to be higher among the older generation.
One 89-year-old woman, Elayne Dykman, told the BBC in Durban she hoped that young people in South Africa did not take their vote for granted.
Additional reporting by Anne Soy in Durban and Barbara Plett Usher in Soweto