POLOKWANE, South Africa - Jacob Zuma triumphed at the African National Congress on Tuesday, parlaying his charisma and widespread popularity to win the governing party's top job and put him in line to become the country's next president.

His overwhelming victory -- 2,329 votes to President Thabo Mbeki's 1,505 -- came despite rape and corruption scandals that had threatened his political career.

Chaos and jubilation erupted as party officials announced the election of Zuma -- a former guerrilla leader who turned an anti-apartheid song, "Bring me my machine gun," into his anthem.

Then he and Mbeki, both 65-year-old veterans of the ANC in exile, mounted the stage and embraced. But the contest was the most bitterly divisive in the history of the party, and Mbeki's loss raised questions about whether he would remain the country's president for the rest of his term.

Zuma was acquitted of rape last year, but could still face bribery charges in a multimillion-dollar arms deal. His supporters say he is innocent and that the scandals were part of a political smear campaign that should not prevent him from becoming ANC president.

Zuma had rallied ANC members who wanted a change from Mbeki, who guided post-apartheid South Africa to sustained economic growth over the past few years, but has been accused of moving too slowly to lift millions out of poverty and being too aloof from the grass roots.

Much has been made of the personality and class differences between Mbeki and Zuma. Mbeki is a foreign-educated academic who sprinkles his speeches with Shakespeare. Zuma had little formal schooling, was a leader of the exiled ANC's military wing, and, like former President Nelson Mandela, served time at the Robben Island prison.

Zuma spent months building his support among the ANC rank-and-file and the trade union movement, but also reached out to religious groups, white Afrikaners and the business community in the final weeks of campaigning.

Supporters of Zuma also won five other top posts, including Kgalema Motlanthe, a former trade unionist and powerful ANC figure, as deputy president, and a top Communist Party official for secretary-general. Given that Zuma may have to step down if prosecutors revive corruption charges against him, the deputy presidency takes on particular significance.

The ANC president is traditionally the party's presidential candidate, and the party is overwhelmingly popular. Mbeki is barred by the constitution from seeking a third term as president of Africa's political and economic powerhouse. But remaining at the helm of the ANC would have given him a say in who succeeds him and in the policies his successor adopts.

In the closing days of the campaign for party leadership, Zuma's supporters were at pains to try to calm fears that South African economic policies would lurch to the left, given the huge support Zuma enjoys among the trade union movement and Communist Party.

Speaking at a press briefing before the results were announced, Zuma ally Motlanthe said there may be a difference in "emphasis," but insisted there "are no ideological differences" within the organization.

Motlanthe clearly wanted to dampen expectations in the powerful Congress of South African Trade Unions, which strongly backed Zuma, saying the federation had no voting rights and so could not claim to have put a candidate in power and expect any "payback."

In an interview later, Zwelinzima Vavi, secretary-general of the union federation, said labor had not expected wholesale policy changes, "but we want a better environment, a respect of different voices."

"We can't hide that we have a class agenda, that things have gone very, very wrong. We see this as a rescue operation," Vavi said.

The main opposition party, which often criticized Mbeki's policies, expressed dismay at Zuma's victory.

"It is an indictment on the ruling party that they could find no better candidate than Jacob Zuma to lead them," Democratic Alliance leader Helen Zille said.

Zuma has called for AIDS and crime to be "treated as national emergencies," something many South Africans have criticized Mbeki for not doing.

However, Zuma has been ridiculed by AIDS activists for testifying in his rape trial last year that he had unprotected, consensual sex with an HIV-positive woman and then took a shower in the belief it would protect him from the AIDS virus. He was acquitted of rape in the case.

For his part, Mbeki has been criticized for questioning the link between HIV and AIDS and was accused of failing to provide leadership to fight an epidemic that has hit South Africa harder than any other country.

On foreign policy, Zuma has challenged Mbeki for insisting on quiet diplomacy over confrontation with neighboring Zimbabwe, where President Robert Mugabe is accused of ruining the economy, undermining democracy and threatening the region's stability.

Mbeki fired Zuma as the country's deputy president in 2005 after Zuma's financial adviser was convicted of trying to elicit a US$70,000 bribe for Zuma to deflect investigations into an arms deal. Charges were withdrawn against Zuma but the National Prosecuting Authority has indicated it may revive them.

During the decades it was an underground movement fighting apartheid, the ANC prided itself on presenting a united front -- the top party post hadn't been publicly contested in 55 years.

But during the conference, delegates loyal to Zuma booed Mbeki allies, carried pictures of Zuma despite a ban on partisan displays and repeatedly disrupted proceedings with "Bring me my machine gun."