"O ye who believe! take not the Jews and the Christians for your friends: They are but friends to each other. And he amongst you that turns to them is of them. Verily Allah guideth not a people unjust." (Surah 5:51) - this is a commonly misquoted verse.
The word "Awliya" does not mean friend it means protector.
5:51 O ye who believe! take not the Jews and the Christians for your protectors: They are but protectors to each other. And he amongst you that turns to them is of them. Verily Allah guideth not a people unjust.
Therefore, the referred verse does not prohibit friendship with Non-Muslims at all.
Dr. Muzammil Siddiqi writes:
The Qur'an does not say that non-Muslims cannot be Muslims' friends, nor does it forbid Muslims to be friendly to non-Muslims. There are many non-Muslims who are good friends of Muslim individuals and the Muslim community. There are also many good Muslims who truly and sincerely observe their faith and are very friendly to many non-Muslims at the same time. Islam teaches us that we should be friendly to all people. Islam teaches us that we should deal even with our enemies with justice and fairness. Allah says in the Qur'an in the beginning of the same Surah Al-Ma’dah:
“O you who believe! Stand out firmly for Allah as witnesses to fair dealings and let not the hatred of others to you make you swerve to wrong and depart from justice. Be just, that is next to piety. Fear Allah, indeed Allah is well-acquainted with all that you do.” (Al-Ma’dah :
In another place in the Qur'an, Allah Almighty says:
“Allah forbids you not with regard to those who fight you not for your faith, nor drive you out of your homes, from dealing kindly and justly with them. For Allah loves those who are just. Allah only forbids you with regard to those who fight you for your faith, and drive you out of your homes and support others in driving you out, from turning to them for protection (or taking them as wali). Those who seek their protection they are indeed wrong- doers.” (Al-Mumtahinah: 8-9)