Praise be to Allah.
This is a matter concerning which rulings may differ according to different circumstances in different times and places. There is no absolute ruling that covers all situations, both real and hypothetical.
In some cases it is wrong to vote, such as when the matter will have no effect on the Muslims, or when the Muslims have no effect on the outcome of the vote. In this case voting or not voting is all the same. The same applies in cases where all the candidates are equally evil or where they all have the same attitude towards Muslims…
It may be the case that the interests of Islam require Muslims to vote so as to ward off the greater evil and to reduce harmful effects, such as where two candidates may be non-Muslims but one of them is less hostile towards Muslims than the other, and Muslims’ votes will have an impact on the outcome of the election. In such cases there is nothing wrong with Muslims casting their votes in favour of the less 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.
No one should imagine that anyone who says that it is OK to vote is thereby expressing approval or support for kufr. It is done in the interests of the Muslims, not out of love for kufr and its people. The 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. This is well known from history. 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.