In a few months time, as winter begins to bite in the southern hemisphere, the African National Congress will face its biggest challenge since it took power in South Africa’s first free elections a quarter of a century ago.

The 25-year milestone will be loudly celebrated. There will be rallies and speeches. The liberation songs that motivated ANC activists during the long, dark decades of its struggle to free South Africa from the racist, repressive apartheid regime will ring out. The memory of Nelson Mandela, Nobel prize laureate, freedom fighter and the country’s secular saint, will be invoked.

But none of this will disguise the harsh reality that 2019 could be the year that will be seen by historians as the beginning of the end for the ANC.

“Twenty-five years is the time when the clock really starts ticking for liberation movements. The ANC is on the defensive now. It is just trying to stop the losses,” said Ralph Mathekga, a South African commentator and analyst.

The general election likely in May or June will be the litmus test for the party.

Last December, Cyril Ramaphosa, 66, won a close-run internal party election. Three months later, he ousted Jacob Zuma to take power as president of the country.

Zuma was accused of presiding over an immense system of corruption and patronage that drained billions from the exchequer and damaged the reputation of the ANC beyond repair. Ramaphosa served as deputy president under Zuma.

Details of alleged graft are surfacing every week as journalists and a judicial inquiry unpick his era.

A 2015 student protest against the then president Jacob Zuma outside the ANC headquarters in Johannesburg. Photograph: Marco Longari/AFP/Getty Images

Though Ramaphosa told reporters in November there was “a new confidence, a new hope in the ANC” and insisted “the shine that had been tarnished is coming back”, the former trade union activist turned tycoon turned politician has struggled to overcome the toxic legacy of Zuma’s nine-year rule.

The economy is weak, expectations are high and Ramaphosa’s broadly centrist market-oriented policies face strong opposition from within his own party.

Entrenched networks of government and ANC officials still loyal to Zuma remain powerful, while international investors, though interested by South Africa’s undoubted potential, are wary.

Successive ANC governments have made huge efforts to build homes and supply basic services to millions of people, but they have been unable to meet expectations. Many people still live without electricity or sanitation. Schooling and healthcare are often rudimentary. One recent survey found eight out of 10 nine-year-olds in South Africa are functionally illiterate. Levels of violent crime are among the highest in the world, with poor South Africans suffering most.

Ramaphosa’s long stint in office under Zuma, and his failure to enact dramatic reform since taking power, leaves him and the ANC vulnerable to the charge from opposition parties that nothing has changed from the bad days before.

South Africa remains a country with enormous resources and great wealth but also vast inequality.

Much of the focus in the last year was on the possible redistribution of farmland – largely owned by white people, who constitute fewer than 10% of the population.

“The ANC is basically buying time. If you want to continue for another 30 years by fair not foul means you do need structural reform and land is one of those,” said Alex Vines, the head of the Africa programme at the Chatham House thinktank in London.

The coming elections could see the ANC share of the vote fall close to 50% for the first time. “The ANC should get a weak majority but this may be the last election it wins,” said Mathekga.

However, the party will be helped by the relative weakness of the opposition. Ramaphosa’s relative moderation has squeezed the political space once occupied by the Democratic Alliance, a centre-right, business-friendly party that is the ANC’s main competitor. The belligerent rhetoric and populist policies of the radical Economic Freedom Fighters plays well with its core constituency but makes further expansion difficult.

A mother walks her children to school in the Alexandra township of Johannesburg. Photograph: Kim Ludbrook/EPA

Leaders of the EFF have also been hit by damaging allegations that they benefited from the corrupt looting of a bank which held savings of some of the poorest members of society.

South Africa, with its particularly traumatic history of racial repression and its high level of industrialisation, has always been something of an exception on the continent. But the country of 55 million people still follows many trends that are evident elsewhere.

Last year the strength of a new wave of young politicians and activists challenging ageing leaders across much of Africa became evident.

The new generation of politicians are in their mid-30s and can barely remember the cold war or the conflicts that brought many autocrats or ruling parties – including the ANC – to power. Often educated and urban, they and their supporters are at the intersection of seismic demographic, social and economic shifts.

More than 10 million eligible voters in South Africa – about a quarter of the electorate – will be under 30 and thus too young to remember the ANC’s role in the struggle against apartheid. A rising proportion live in towns and cities, not the rural zones that are the bedrock of ANC support.