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 percent of the vote in Wednesday’s election, according to results announced by South Africa’s electoral commission after 95 percent of votes were counted. In 2014, the party received 62 percent of the total vote.

The main opposition party, the Democratic Alliance, had 20 percent of the vote as of Friday, down from the 22 percent 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.”

WATCH: Why immigration is a focal issue in South African election

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 percent from 74 percent 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 percent to 10 percent.

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.