Mmusi Maimane, leader of the largest opposition party, the Democratic Alliance, speaks to the media as he visits the Independent Electoral Commission Results Center in Pretoria, South Africa Friday, May 10, 2019. The ruling African National Congress held a comfortable lead in South Africa's presidential and parliamentary election with more than two-thirds of the vote counted Thursday, but the incomplete count showed the party received less support than in the last balloting five years ago. (AP Photo/Jerome Delay)

PRETORIA, South Africa (AP) — The ruling African National Congress was on course to win South Africa's presidential and parliamentary elections by a comfortable margin with almost all votes counted Friday, but the tally showed the party lost support from five years earlier amid deep anger over corruption.

The ANC, led by President Cyril Ramaphosa, had 57% of the vote in Wednesday's election, according to results announced by South Africa's electoral commission after 95% of votes were counted. In 2014, the party received 62% of the total vote.

The main opposition party, the Democratic Alliance, had 20% of the vote as of Friday, down from the 22% it received in the last election. On Friday, 35 smaller parties jointly lodged a complaint with the electoral commission, complaining of irregularities and calling for an audit of the vote and a possible rerun of the election.

The ANC's lead, despite its reduced margin, was seen by many as a mandate for Ramaphosa to keep working to clean up corruption within the party that inspired South Africa under Nelson Mandela's leadership.

Another former ANC leader, Jacob Zuma, resigned as president last year amid numerous corruption allegations.

"It's now up to Ramaphosa to clean up the ANC, to stop the looting in government," said commentator Barney Mthombothi. "He can argue that the ANC lost its share of the vote because of the rampant corruption under the previous Zuma leadership."

In the campaign, Ramaphosa acknowledged the problem of graft in the party, which has governed South Africa since the end of apartheid 25 years ago. He vowed not to have any corrupt members in his Cabinet.

"After he voted in Soweto, Ramaphosa pledged to root out corruption," said Mthombothi. "He will have to deliver decisively on those words."

The results will embolden Ramaphosa, as the party probably would have performed worse if he was not at the helm, said political analyst Karima Brown.

"He has positioned himself as a president who is focused on rooting corruption out of government," said Brown. "The fact of the matter is that he is more popular than the ANC, and that has shown in this election." She cited the example of the Western Cape province where people split their vote by voting nationally for Ramaphosa but for provincial elections, voting for the opposition Democratic Alliance.

However the resistance that Ramaphosa still faces within his party was evident by remarks made Friday by ANC secretary general Ace Magashule, who is considered to lead the ANC faction opposed to the president. He said the ANC's victory could not be attributed to Ramaphosa alone.

"This was the responsibility of the whole organization, the members on the ground and all the leadership," said Magashule.

Voter apathy also has been a factor, as turnout dipped to 65% from 74% in 2014.

"Even though we've lost a few votes, we've held the center of South Africa politics," Mmusi Maimane, the Democratic Alliance party leader, said Friday at the electoral commission's results center in Pretoria. "We will work to regain those votes because we are the party for all South Africans of whatever race."

The populist, left-wing Economic Freedom Fighters increased its share of the vote from 6% to 10.

In South Africa, the president and parliament are not elected directly. The number of votes won by each party determines how many representatives are sent to the national 400-seat legislature. The president of the country is the leader of the party that gets the most votes.

The remaining results from South Africa's more remote areas are trickling in, and electoral officials say final results will be announced Saturday afternoon.

___

Follow Africa news at http://twitter.com/AP_Africa

Mmusi Maimane, leader of the largest opposition party, the Democratic Alliance, addresses the media as he visits the Independent Electoral Commission Results Center in Pretoria in Pretoria, South Africa Friday, May 10, 2019. The ruling African National Congress is coasting to a comfortable lead in South Africa's presidential and parliamentary elections with 80% of the vote counted, but the ongoing tally shows the party getting less support than in the previous poll five years ago. (AP Photo/Ben Curtis)
Mmusi Maimane, leader of the largest opposition party, the Democratic Alliance, addresses the media as he visits the Independent Electoral Commission Results Center in Pretoria in Pretoria, South Africa Friday, May 10, 2019. The ruling African National Congress is coasting to a comfortable lead in South Africa's presidential and parliamentary elections with 80% of the vote counted, but the ongoing tally shows the party getting less support than in the previous poll five years ago. (AP Photo/Ben Curtis)
Mmusi Maimane, leader of the largest opposition party, the Democratic Alliance, addresses the media as he visits the Independent Electoral Commission Results Center in Pretoria in Pretoria, South Africa Friday, May 10, 2019. The ruling African National Congress is coasting to a comfortable lead in South Africa's presidential and parliamentary elections with 80% of the vote counted, but the ongoing tally shows the party getting less support than in the previous poll five years ago. (AP Photo/Ben Curtis)
Mmusi Maimane, leader of the largest opposition party, the Democratic Alliance, speaks to the media as he visits the Independent Electoral Commission Results Center in Pretoria, South Africa Friday May 10, 2019. The ruling African National Congress held a comfortable lead in South Africa's presidential and parliamentary election with more than two-thirds of the vote counted Thursday, but the incomplete count showed the party received less support than in the last balloting five years ago. (AP Photo/Jerome Delay)
A gathering of representatives of smaller parties march to take the stage to protest their claim that the elections were not free or fair, at the Independent Electoral Commission Results Center in Pretoria, South Africa Thursday, May 9, 2019. South Africans voted Wednesday in a national election and preliminary results show that the ruling African National Congress party (ANC) has an early lead in the national elections but has seen its share of the vote drop significantly. (AP Photo/Ben Curtis)
A gathering of representatives of smaller parties take to the stage to protest their claim that the elections were not free or fair, at the Independent Electoral Commission Results Center in Pretoria, South Africa, Thursday, May 9, 2019. South Africans voted Wednesday in a national election and preliminary results show that the ruling African National Congress party (ANC) has an early lead in the national elections but has seen its share of the vote drop significantly. (AP Photo/Ben Curtis)
Mmusi Maimane, leader of the largest opposition party, the Democratic Alliance, is greeted by a supporter as he visits the Independent Electoral Commission Results Center in Pretoria, South Africa Thursday, May 9, 2019. South Africans voted Wednesday in a national election and preliminary results show that the ruling African National Congress party (ANC) has an early lead in the national elections but has seen its share of the vote drop significantly. (AP Photo/Ben Curtis)
Mosotho Moepya, a Commissioner of the Independent Electoral Commission (IEC), speaks at the podium at the results center in Pretoria, South Africa Thursday, May 9, 2019. South Africans voted Wednesday in a national election and preliminary results show that the ruling African National Congress party (ANC) has an early lead in the national elections but has seen its share of the vote drop significantly. (AP Photo/Ben Curtis)