A:
Allegiance must be given to the Muslim ruler promising compliance and obedience, as the Companions did with the Prophet (peace be upon him) and as Muslims did with the Rightly-Guided Caliphs.
However, pledging allegiance to other than the Muslim ruler is an invalid Bid`ah (Islamic innovation). The Prophet stated:
Anyone who does an action which is not stated in this matter of ours (Islam) will have it rejected.
And in another narration:
Anyone who introduces anything into this matter of ours (Islam) that is not part of it will have it rejected.
(Agreed upon by Al-Bukhari and Muslim). Whoever declares his faith, their Islam is valid provided that he commits to the tenants of Islam, even if he does not pledge allegiance. The Prophet (peace be upon him) used to teach people Islam and accept one's testimony of faith without taking a pledge from them. It is known from other proofs that a Muslim must comply with and obey Muslim rulers, even if he does not pledge allegiance. (Part No. 2; Page No. 280) May Allah grant us success. May peace and blessings be upon our Prophet Muhammad, his family, and Companions.