All perfect praise be to Allaah, the Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
The pledge of allegiance is one of the greatest blights associated with endeavoring to get the citizenship of a non-Muslim country. It consists of various vicious matters, including what is related to Kufr (disbelief) itself, like allegiance to the laws of those countries.
We would like to first make note that one of the most dangerous matters occurring in this time is that some Muslims are rushing and striving to obtain the citizenship of a non-Muslim country without dire necessity. This results in many evils against the Muslim in his religion and his worldly affairs. Muslims must beware of venturing into this for an insignificant reason; as the end could be that one sells his religion for worldly gain, thus losing out in both this life and the Hereafter; and that is manifest loss.
For more benefit, kindly refer to Fataawa 82552 and 87140. We have explained in them that in case of dire necessity, a Muslim who gives the pledge of allegiance to one of these governments may conceal his intention and use Tawriyah (i.e. saying something which has more than one meaning and intending a meaning different from what the listener is likely to understand), like to intend his allegiance only to the Muslims in those lands and to benefit that country by guiding its people to enter Islam.
However, the Muslim does not become a disbeliever by merely repeating these words which contain allegiance to the people of Kufr, as long as his heart remains at rest with faith. Al-Qurtubi commented in his Tafseer (interpretation of the Quran) on the story of Haatib (ibn Abi Balta‘ah) and what was revealed regarding it at the beginning of Soorah Al-Mumtahanah that Allaah The Exalted said (what means): {O you who have believed, do not take My enemies and your enemies as allies, extending to them affection while they have disbelieved in what came to you of the truth.}[Quran 60:1] saying: "The saying of Allaah The Exalted: {extending to them affection} means to do so outwardly, since the heart of Haatib was without fault. The evidence is that the Prophet, sallallaahu ‘alayhi wa sallam, said to them (his Companions): “As for your companion (Haatib), he has been truthful.” This is a statement of the soundness of his heart and the purity of his belief … The one who is mostly acquainted with the Muslims' locations of privacy, and then he informs their enemies about them, and tells them their news is not necessarily thereby a disbeliever if he did so merely for some worldly purpose. This is exactly what Haatib did when he intended to seek protection [from the people of Makkah for his family there], and he never intended apostasy from his religion." [End quote]
Allaah Knows best.