Jacob Zuma, a populist whose career survived rape and corruption charges, was elected leader of the governing African National Congress on Tuesday, putting him into position to become South Africa's next president.
Zuma received 2,329 votes, ahead of incumbent Thabo Mbeki's 1,505 votes, following one of the most divisive campaigns the party has seen.
Chaos erupted in the hall as the results were announced, then Mbeki and Zuma mounted the stage together and embraced.
Zuma had rallied ANC members who wanted a change from Mbeki, who guided post-apartheid South Africa to sustained economic growth in recent years but has been accused of moving too slowly to lift millions out of poverty.
Zuma still risks being charged by prosecutors for corruption in a multimillion-dollar arms deal. His supporters said the corruption cloud was part of a political smear campaign and should not prevent him from becoming ANC president.
Zuma loyalists also won overwhelming support for the positions of deputy president and secretary general.
The bitter contest for party president strained the organization's fabled discipline and unity. But the margin of Zuma's victory raised questions whether Mbeki would continue as national president until scheduled elections in 2009 or whether he would step down early. The ANC candidate would likely win, given the party's wide support.
In the closing days of the campaign, Zuma's supporters were at pains to try to calm jitters that South Africa's economic policies would lurch to the left, given the huge support he enjoys among the trade union movement and Communist Party.
As delegates headed into the university hall to hear the results, Zuma supporters sang out his now trademark anthem "Bring Me My Machine Gun." Mbeki's supporters were huddled in a prayer meeting.
"The reality is that the tsunami is unstoppable," Zuma supporter Jappie Mateis said after voting, referring to the support for his candidate popularly called the "Zunami."
Much has been made of the personality and class differences between Mbeki and Zuma, former allies who are both 65 and spent years in exile during apartheid.
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 many months building his support among the 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.
He has insisted that he will not radically change the economic agenda for fear of scaring off foreign as well as domestic investors. He has called for AIDS and crime to be "treated as national emergencies," something many South Africans have criticized Mbeki for not doing.
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 thereby threatening the region's stability.
Mbeki is barred by the constitution from seeking a third term as president of Africa's political and economic powerhouse.
Mbeki fired Zuma as the country's deputy president in 2005 after Zuma's financial adviser was convicted of trying to elicit a $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.
Last year, Zuma was acquitted of raping a family friend. During the trial, he testified that he had unprotected, consensual sex with the HIV-positive woman and then took a shower in the belief that it would protect him from the AIDS virus.
His supporters accused the Mbeki camp and the media of unfairly vilifying Zuma.
"He is innocent until proven guilty," said Sihle Mbili of the corruption cloud that still hangs over Zuma's head. "If he is found guilty, it means no crisis of leadership in the ANC as we have got a deputy president. But we will cross that bridge when we get to it."
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 leaders seen as Mbeki allies and carried pictures of Zuma despite a ban on partisan displays.