Cheering broke out at the AU's headquarters as supporters of Dlamini-Zuma, 63, celebrated her victory over the incumbent Jean Ping of Gabon.
"We made it!" a grinning Zimbabwean delegate shouted, reflecting the strong support Dlamini-Zuma's candidacy received from fellow members of the Southern African Development Community.
The South African president, Jacob Zuma, former husband of the winning candidate, emerged from the conference hall where the voting had taken place to announce that "Africa is happy!" Her victory would empower women, he added.
Dlamini-Zuma is the first woman to lead the continent since the Organisation of African Unity, later the AU, was founded in 1963. She is also the first from southern Africa. She faces the challenge of revitalising a body often criticised for its slow and ineffective response to crises such as those in Ivory Coast and Libya last year.
Dlamini-Zuma's victory was far from certain. She had stood against Ping in elections in January, which ended in a stalemate that extended Ping's term in office by a further six months until a fresh ballot could be held.
In this first contest, neither candidate managed to secure the two-thirds majority needed for an outright win but Ping garnered slightly more support than his opponent.
Many observers felt it would be difficult for Dlamini-Zuma to overcome the widespread discontent with South Africa for breaking the unwritten convention that the five largest contributors to the AU budget – Nigeria, Egypt, Libya, Algeria and South Africa – should not contest the commission's highest office.
Both Nigeria and Egypt, whose strategic interests would not have been served by a South African victory, were strongly in the Ping camp. There are concerns that South Africa, the continent's biggest economy, will use its position as AU chair to further its efforts to secure a permanent African seat on an expanded UN security council.
There had also been widespread scepticism in the South African press, which branded the country's campaign "quixotic".
But hard lobbying from the South African government and its regional partners turned the tide for Dlamini-Zuma. The campaign became personal towards the end of the contest with tempers flaring on both sides. Ping made an angry riposte to allegations in the South African press regarding his candidacy and campaign financing last week that lost him critical support.
His chances of victory were further undermined by the absence of two of his key champions – the continued threat of attack from Islamist militants kept the Nigerian president, Goodluck Jonathan, at home, while Meles Zenawi, Ethiopia's prime minister and the summit's host, has yet to make an appearance at the meeting and is rumoured to be seriously ill and receiving treatment in Europe.
As in January, the election went the distance. In the first round, Dlamini-Zuma had a narrow advantage, beating Ping by 27 votes to 24. In the second she extended her lead, gaining two more votes. By the third she was just one vote short of the 34 needed to secure a two-thirds majority. She contested the fourth and final round alone and managed to succeed where Ping had failed, winning support from 37 out of the 51 eligible member states.
Yoweri Museveni, president of Uganda, welcomed the result, believing Dlamini-Zuma will be a strong advocate for the continent. "We are used to diplomats and bureaucrats," he said. "Her background as a freedom fighter, this is value addition."
He felt that the rifts exposed by the election had been healed "because we agreed" on Dlamini-Zuma.
Zuma concurred. "I think the AU has done the right thing," he said. "Southern Africa is happy but the whole of Africa is happy." The appointment of Zuma's ex-wife removes her as a potential focal point for opposition to his candidacy before elections in South Africa in 2014.
Before the vote rumours spread of a compromise third candidate. Mohammed Ibn Chambas, a former president of the west African regional block Ecowas, and Joaquim Chissamo, the ex-president of Mozambique, were among those named.
Erastus Mwencha, a Kenyan, the vice-chairman of the AU commission, was re-elected to serve a second term. His support was almost unanimous, with 50 out of a possible 51 votes, and his victory breaks another unwritten convention that dictates that the chair and vice-chair are held by one francophone and one anglophone country. At a press conference before the election, Dlamini-Zuma said that if appointed chair she would assess "what is not working well and what can be strengthened".