All praise be to Allaah.
The ruling for this matter may differ according to different circumstances in different times and place. There is no absolute ruling that covers all situations. It is the matter of what circumstances are prevailing in that place.
In some cases, it can be considered wrong to vote such as when the election will have no impact on Muslims or when the outcome of voting has no benefit for Muslims. In such cases voting or not is all same. Similarly when all candidates are evil or where they all have same attitude towards Muslims then voting should not be participated into.
In some cases if both the candidates are not Muslims but one among them is less hostile towards Islam and Muslims then, in that case, a muslim can vote and there is nothing wrong with that as their voting is casting away a greater evil in favor of the less evil candidate. It is the case in the interest of Islam and requires Muslims to vite so as to ward of greater evil and reduce the harmful effects of evil candidate.
In any case, this is the matter of ijtihaad based on the principle of weighing up the pros and cons, what is in the interests of Islam and what is detrimental. With regard to this matter, we have to refer to the people of knowledge who understand this principle. We should put the question to them, explaining in detail the circumstances and laws in the country where the Muslim community is living, the state of the candidates, the importance of the vote, the likely benefits, and so on.
It should not be thought that anyone who says it is OK to vote is supporting kufr and is expressing approval of their ways and people. It must be understood that voting must be done in the interest of Muslim not out of love towards the people of kufr. It is very well known from the history that Muslims rejoiced when the Romans defeated the Persians, as did the Muslims in Abyssinia (Ethiopia) when the Negus defeated those who had challenged his authority. Whoever wants to be on the safe side and abstain from voting is allowed to do so. This response applies only to elections for influential positions. And Allaah knows best.