Today, we find Muslim countries making military alliances with the kuffar and fighting alongside them. Turkey is a member of NATO and has sent troops to Afghanistan under the UN International Security Assistance Force.
Pakistan has entered a military alliance with America to fight Muslims in the tribal areas and support the Afghan war.
Many Muslim countries participate in numerous other military alliances and collective security agreements.
Historically, the Khilafah entered in to military alliances with kafir states at certain times.
In America and Europe we find a small minority of Muslims joining the western armies and being sent to Iraq and Afghanistan with some scholars even issuing fatwas that this is permissible in Islam.
The Islamic ruling on military alliances and their permissibility is given below. This is taken from the book Shakhsiya Islamiyya (Islamic Personality) Volume 2 by Sheikh Taquideen an-Nabhani. The extract below is based on a draft translation from Arabic.
"Al-hilf" linguistically means covenant (‘ahd) and friendship. It is said "halifuhu" derived from "'ahiduhu" (he covenanted with him). However, the technical definition of the word "al-hilf" specifically means military alliance.
Military alliances are the alliances contracted between two or more states that make their armies fight together with a common enemy, or exchange military intelligence and weapons between them, or if one of them enters in to war they will consult with the other state to enter war with them or not according to the interests they see.
These alliances could be dual treaties (mu'ahadat thinaiyya) contracted between two, three or more states, but they do not consider aggression upon one state as an aggression against all of them. Rather if aggression occurs upon one of the treaty states, the other states with which it has a military alliance have the option of joining the war alongside the state facing aggression or not according to what is in their interests.
These alliances could also be collective alliances in which aggression against one of the treaty states is an aggression against all of them. So if war occurs between one treaty state and another state then the other states with which it has a military alliance will enter the war alongside it.
All of these alliances, whether they were dual, collective or other than these, necessitate that the army fights with its ally to protect it and its entity whether there were numerous leaders or a single leader.
These alliances are void from their basis and are not contracted legitimately in Islam. The Ummah is not obliged to follow them even if the Muslims' Khaleefah contracted them since they contradict the Shar'a. This is because these alliances make the Muslim fight under a kafir leadership, under a kufr banner, in order to preserve a kufr entity, all of which is haram. It is not allowed for a Muslim to fight except under a Muslim leadership and under the Islamic banner.
There came a prohibition in the sahih hadith against fighting under the disbelievers' banner and their leadership.
Ahmad and An-Nisa'I narrated from Anas who said: The Messenger of Allah صلى الله عليه وسلم said: "Do not seek light with the fire of polytheists." i.e. do not make the polytheists' fire a light for you.
The fire is an indication of war. It is said the "fire of war was kindled" (awqada nar) i.e. its evil and violent passion was called into existence. The fire of fright (tahweel) is a fire the Arabs in jahiliyyah would kindle during alliances. The hadith alludes to war with polytheists and adopting their banner, so the prohibition of war together with polytheists is understood from it.
Alliances would also make the disbelievers fight with Muslims while preserving their entity i.e. they would fight as a state and not individuals. The Messenger prohibited seeking assistance of the disbelievers as an entity.
It came in the hadith of Adh-Dhahhak (RA), "that the Messenger of Allah صلى الله عليه وسلم went out on the day of Uhud, when all of a sudden there was a good squadron or a harsh squadron so he صلى الله عليه وسلم said: ‘Who are these?' They said: ‘The Jews of so and so.' So he صلى الله عليه وسلم said: ‘We do not seek assistance of disbelievers.'"
Al-Bayhaqi said: The authentic report is what Al-Hafidh Abu Abdullah informed us via a chain leading to Abu Hameed as-Sa'idi who said: "The Messenger of Allah صلى الله عليه وسلم went out until he left behind Thaniyya al-Wada', and all of a sudden there was a squadron. He said: ‘Who are these?' They said: ‘Banu Qaynuqa and they are the people of Abdullah bin Salam.' He صلى الله عليه وسلم said: ‘Have they embraced Islam?' They said: ‘Rather they are on their deen.' He صلى الله عليه وسلم said: ‘Tell them to return for we do not seek assistance of the polytheists."
The Messenger صلى الله عليه وسلم rejected assistance from the Jews and said in general manner: "We do not seek assistance of the disbelievers...We do not seek assistance of the polytheists."
One should not say that we seek assistance with disbelievers against our enemy and seeking assistance with the disbeliever is allowed because the Messenger صلى الله عليه وسلم consented to Quzman fighting together with him in Uhud and he was a disbeliever, and he صلى الله عليه وسلم accepted assistance from some Jews of Khaybar in war. One should not say this because seeking assistance with disbelievers is allowed if they are individuals under the Muslims' banner. Those whom the Messenger صلى الله عليه وسلم sought assistance from were individuals not an entity or state.
When Banu Qaynuqa came to the messenger صلى الله عليه وسلم they came as a tribe with their own leader, and they were like a state that previously made a treaty with the Messenger of Allah صلى الله عليه وسلم. They came to fight with the Messenger صلى الله عليه وسلم and they were upon this situation and it was said to him: "They are the company of Abdullah bin Salam" so he refused to seek assistance from them due to this. Accordingly it is not allowed to seek assistance from a kafir army and under the banner of their disbelieving state.
Imam As-Sarakhsi said in ‘Al-Mabsut' in the book of ‘Siyar': "From the hadith of Adh-Dhahabi (ra) ‘that the Messenger of Allah صلى الله عليه وسلم went out the day of Uhud where there was a husna squadron or he said khushna. So he صلى الله عليه وسلم said: Who are these? They said: The Jews so and so. So he صلى الله عليه وسلم said: We do not seek assistance of disbelievers.' Its interpretation (ta'weel) is that they were powerful in themselves not fighting under the Muslims' banner. For us, we only seek assistance from them if they were fighting under the Muslims' banner whereas if they come independent with their own banner then we do not seek assistance from them. This is the interpretation of what was narrated when the Prophet صلى الله عليه وسلم said: ‘Do not seek light from the fire of the polytheists' narrated by Ahmad and An-Nisa'I via the way of Anas and he صلى الله عليه وسلم said: "I am free (bariu) from every Muslim who fights together with a polytheist' meaning if the Muslim is under the polytheists' banner."
From this it becomes clear that military alliances with disbelieving states are haram in the Shar'a and they are not contracted.
It is not allowed for the Muslim to shed his blood in the way of defending the belligerent disbeliever. Rather the Muslim only fights people so that they enter into Islam from disbelief (kufr). As for fighting disbelievers to enter from kufr into kufr and to shed his blood for that, this is also haram.