By Joe Brock

PORT ELIZABETH, South Africa (Reuters) - On the surface, white South African ex-farmer Athol Trollip seems an unlikely candidate for mayor of a metropolitan district named after the ANC's great liberation hero, Nelson Mandela.

Yet local elections this week have shown a shift in South African society and politics, which have been dominated by race since Mandela swept to power in 1994.

The results may even mark the start of a new era, distinct from the 'post-apartheid' period that immediately followed the end of white-minority rule, as the African National Congress wakes up to the changed reality that it can no longer rely on the unquestioning support of poor black voters.

Angry about corruption, unemployment and shoddy basic services, many ANC supporters have turned to the opposition Democratic Alliance (DA) - making a switch that was unthinkable only a few years ago when the party was still seen as the political home of wealthy whites.

Voters have also become disillusioned by festering inequality; black people make up 80 percent of the 54 million population yet, two decades after apartheid, most of the economy in terms of ownership of land and companies remains in the hands of white people, who account for about 8 percent of the population.

DA candidate Trollip, a fluent speaker of the local Xhosa language, is likely to become mayor of the Nelson Mandela Bay municipality after his party won 47 percent of the vote against the ANC's 41 percent, down from 52 percent five years ago.

The DA is now expected to form a coalition with smaller opposition parties to run a region that has been an ANC stronghold for more than two decades.

Besides Mandela, who grew up in the nearby village of Qunu, the Port Elizabeth area was home to anti-apartheid luminaries such as former President Thabo Mbeki and his father Govan, and Steve Biko, the Black Consciousness leader killed in police custody in 1977.

The ANC has also lost its majorities in Johannesburg and the municipality that is home to the capital Pretoria, in its biggest ever election losses, which have dealt a significant blow to President Jacob Zuma.

ANC chief whip Jackson Mthembu said the party was chastened by the results. "We need to have a serious introspection," he told reporters at the main counting center in Pretoria.

The DA also boosted its majority in Cape Town to more than two-thirds, a resounding vote of confidence in its ability to govern.

RACE CAMPAIGN

During campaigning, the ANC spent much time and money reminding voters of its liberation legacy and of the DA's white roots, even comparing the party to the former apartheid regime.

On the eve of voting, Trollip's ANC opponent, Danny Jordaan, said the DA strategy of invoking Mandela's name and ideas during its campaign was akin to nailing Jesus to the cross and the next day claiming you were a Christian.

Some black voters were also told they would be "black Boers" if they chose the DA, a derogatory reference to Afrikaans-speaking white farmers.

"The ANC's racially charged campaign strategy has backfired spectacularly," Trollip told Reuters as his team celebrated what he called an "historic victory".

"Mandela promoted 'non-racial' politics and the ANC has just gone in reverse in a desperate attempt to keep votes. People want sound policies and delivery, not rhetoric."

The DA has also benefited from an image change, promoting a diverse range of candidates including its first black leader, 36-year-old part-time preacher Mmusi Maimane, who has headed the party since last year.

With solid support in rural areas, the ANC still has majority support across the country, a reflection of its liberation struggle history and the significant improvement in basic living standards for poor South Africans since apartheid.

However, its share of the total vote, projected at 54 percent, represents a big drop from 62 percent five years ago.

The radical leftist Economic Freedom Fighters (EFF), who appeal mainly to young black voters frustrated with lingering inequality, also bit into the ANC majority, winning 8 percent in its first local election.

In some almost exclusively black wards in Nelson Mandela Bay, the DA won up to 20 percent of the vote after barely registering in 2011.

"The DA has a lot more appeal than before," said 30-year-old Port Elizabeth township resident Chimone Ferreira, who voted for the DA for the first time this week.

"We want our lives to improve and that hasn't happened since 1994 when there was so much love for the ANC."

'NIGHTMARE COME TRUE'

The ANC's defeat in a region named after Mandela is a major embarrassment and could prompt a challenge to Zuma, whose folksy 'man of the people' appeal has been damaged by scandal and his struggle to understand the needs of a sophisticated emerging market economy.

"The DA is crawling its way into African townships. It's a nightmare come true for the ANC and Jacob Zuma," said Daryl Glaser, head of political studies at Johannesburg's Witwatersrand University.

"It's very damaging for Zuma but not necessarily terminal. He's proven remarkably resilient in the past."

If the DA is to capitalize on gains this week and broaden its appeal ahead of a general election in 2019 it will need to prove it can redistribute wealth to benefit the black majority.

"Where I come from, there is a lot of pressure to vote for the ANC," said Tando, declining to give his last name due to the stigma attached to the DA in his township, where dirt tracks wind between makeshift shacks.

"We've given the DA a chance to show what they can do. I hope they don't let us down."

(Editing by Ed Cropley and Pravin Char)