You have asked an important question as there are lot of misgivings among many Muslims on this issue.
To arrive at a sound judgement on this issue, we must keep in mind three important points. Let me state them up front before coming to the question directly:
Islam, as the Qur'an makes it abundantly clear, is all about peace, justice and compassion towards all; it abhors racism, xenophobia, and aggression. We read in the Qur'an, "Allah enjoins justice, and the doing of good, and generosity towards [one's] fellow-men; and He forbids all that is shameful and all that runs counter to reason, as well as envy; [and] He exhorts you [repeatedly] so that you might bear [all this] in mind." (Qur'an: 16: 90)
Justice and compassion in Islam extends to all, Muslims and non-Muslims alike, as it has been made abundantly clear in numerous verses. (See for instance: Qur'an: 5: 8; 6: 152)
Secondly, it is common knowledge that the Prophet, peace be upon him, won over his most ardent foes through his magnanimity and kindness. Abu Sufyan, Safwan, Suhyl, Ikrimah, Thumamah and Adiyy b. Hatim were only a few among many; who, once his arch-enemies, became his ardent supporters.
Thirdly, Qur'an orders the believers to join common cause with everyone on furthering virtue and God-consciousness: "Help one another in furthering virtue and God-consciousness, and do not help one another in furthering evil and enmity; and remain conscious of God: for, behold, God is severe in retribution!" (Qur'an: 5: 2)
That the above order extends to all people is born out by the clear statements of the Prophet, "By Allah, if the Quraysh were to a joint venture for honouring sanctities and redressing injustice, I would hasten to join it!" He also praised the pact of virtue, which certain members of Quraysh had made in pre-Islamic times, and said that he would join a similar pact, not matter who calls for it.
It is therefore clear from the above that we are allowed to befriend and join in alliance with all peoples for the common good.
Now the question arises what to make of those verses in the Qur'an (see for instance: 3: 28; 4: 139-140; 5: 51, etc.) which seem to imply that Muslims are not to make allies and partners of non-believers, including Christians and Jews. The answer is: that such verses must be studied in their specific contexts. In other words, they were revealed in the context of alliances that the hypocrites in Madinah made with the Jews of Madinah, who, in breach of the pacts they had made with the Prophet, secretly colluded and conspired with the Quraysh against the Prophet, peace be upon him, and Islam. Thus all verses that warn against befriending non-believers are to be explained as an interdict against joining with the enemies of Islam. Furthermore, as it has been made clear in the previous verses, even as Muslims ought to join with all in furthering virtue, likewise, they are ordered to stand united against those who work for corruption, vices, bloodshed and aggression or undermine religion and morality.
In conclusion, while Muslims are to act fairly and compassionately towards all people, they should declare their innocence of those who oppose values such as faith, morality, virtue, peace, justice and compassion.