From Civilization V Wiki
When a player learns the "Globalization" technology, he or she can construct the United Nations. Once that is constructed, a vote will be taken every few turns for the position of World Leader. If a leader gets enough votes to win the position, he or she immediately wins a diplomatic victory. The amount of votes needed to win a diplomatic victory depends upon the number of civilizations in play at the start of the game.
All civilizations and city-states have a vote. The civilization which possesses the United Nations has two votes.
Civilizations always vote for themselves, unless liberated, in which case they vote for their liberator (see below).
City-States vote for the civilization with the best relations, unless they've been liberated, in which case they vote for their liberator.
If you take a city-state that has been captured by another civilization, you have the choice to annex the city-state, make it a puppet, or liberate it. If you choose to liberate a city-state, then it will always vote for you in UN elections, no matter what its relations are with you at the time of the vote. If the same city-state has been liberated twice, it will vote for the civ which liberated it most recently.
If a civilization has been removed from the game and you capture one of those civ's cities, you have the option of annexing it, making it your puppet, or liberating it. If you do so, the civilization returns to play. The liberated civ will always vote for you in UN elections. In case of multiple liberators, the civ will vote for whoever liberated them most recently.