Azerbaijan has for the first time secured a seat on the UN Security Council after the country running against it, Slovenia, dropped out of the race.
Azerbaijan's victory was confirmed when it received 155 votes in the 193-nation UN General Assembly.
Azerbaijan joins Pakistan, Morocco, Guatemala and Togo as temporary members of the 15-nation council in January for a two-year term.
Those four nations were elected to the council on October 21.
Slovenia and Azerbaijan along with Hungary were vying for a seat reserved for Eastern Europe. Voting started on October 21 and 16 rounds of voting failed to produce a winner, in one of the most competitive council elections in years.
In announcing his country's decision on the floor of the General Assembly, Slovene Foreign Minister Samuel Zbogar said his country "did not approve" of how the elections were held, although he failed to elaborate.
Azeri Foreign Minsiter Elmar Mammadyarov said his country was the deserved winner.
"Of course feelings you can imagine after the 17 rounds of voting, all the ballots. I think that we, honestly speaking, expect that we are going to be elected, because on Friday evening and this all the day, the tendency was that the General Assembly mostly voting and supporting Azerbaijan," said Mammadyarov following the vote.
Western diplomats in New York said Azerbaijan could join countries opposed to U.S. and EU efforts for UN sanctions against Iran or Syria next year.
compiled from agency reports