The African Union has chosen South African Nkosazana Dlamini-Zuma as its leader, making her the first woman to hold the post.
Ms Dlamini-Zuma beat incumbent Jean Ping of Gabon after a closely fought contest for the chairmanship of the organisation.
In January, neither got the required two-thirds majority, leaving Mr Ping in office for another six months.
The dispute has overshadowed other issues, especially security and trade.
Voting had been broadly split along linguistic lines, with English-speaking countries tending to support Ms Dlamini-Zuma and French-speaking countries lining up behind Mr Ping.
Senior officials had warned that failure to resolve the leadership deadlock would divide the AU and undermine its credibility.
Ms Dlamini-Zuma, the former wife of South African President Jacob Zuma, won the leadership of the AU commission in a third round of voting.
She got 37 votes at the 54-member body, giving her the 60% majority she needed to be elected.
The 63-year-old is currently South Africa's home affairs minister, and has also had spells as minister of health and of foreign affairs.
She is one of her country's longest-serving ministers.
But critics said her candidacy had broken an unwritten tradition that the chairmanship should not be occupied by one of Africa's major nations.
Earlier this week, Mr Ping denied a South African media report speculating he was going to withdraw from the race.
His use of the AU's website and letterhead for his statement prompted the southern African regional bloc Sadc to accuse him of misusing AU resources for his re-election bid.
Ms Dlamini-Zuma's election came at a summit in Addis Ababa, the organisation's home city.
As in January, the official theme of the summit was boosting intra-African trade.
It is also due to focus on the continuing instability in Mali, mounting violence in the eastern Democratic Republic of Congo and tension between Sudan and South Sudan.