Ramaphosa who is the party and country's deputy president had a tight contest with the former AU Commission chairperson, Nkosazan Dlamini-Zuma for the ANC president position.
The elections were conducted by EleXions Agency, Xinhua news agency reported.
EleXions Agency Director Bontle Mpakanyane, when announcing the results said, "Nkosazana Dlamini Zuma got 2,261 and Cyril Ramaphosa got 2,440. I, therefore, declare Cyril Ramaphosa as president of the African National Congress."
The Mpumalanga premier, David Mabuza was elected the ANC deputy president after beating the Human Settlements Minister, Lindiwe Sisulu.
Paul Mashatile becomes the party's treasurer general after beating the International Relations and Cooperation Minister, Maite Nkoana-Mashabane.
The former ANC General Secretary Gwede Mantashe beat the Arts and Culture Minister Nathi Mthethwa to become the national party chairperson, while Ace Magashule was elected the party general secretary after beating Senzo Mchunu.
Jessie Duarte who was the party deputy general secretary was retained in the same post after beating Zingiswa Losi.
The ANC electoral commission chairperson, Sindiso Mfenyana thanked the outgoing ANC leaders who served in the party leadership.
Baleka Mbete, outgoing ANC chairperson said, "I would like to thank the conference for disappointing those who thought this conference won't come together. This conference has been a success even though it is not yet finished. It was disciplined. I ask you to cooperate with the new determined and winning leadership as we move towards 2019."
The country will hold the presidential and parliamentary elections in 2019.