In the beginning of Islam the Muslims were commanded that if the enemies of Islam sought, as they in fact did, to wipe out Islam, by force, they were not to take up the sword in opposition to them. But then a time came when it was announced: Permission to fight is granted to those against whom war is made, because they have been wronged and Allah indeed has the power to help them (22:40). This meant that the wrongdoing of the enemies having reached its extreme limit, the Muslims were permitted, for the safeguarding of the freedom of conscience and freedom of belief, to take up the sword against the sword of the enemy and to continue to wield it till freedom of conscience and freedom of belief were firmly re-established in human society according to God’s design.
In another verse it is said: They will not stop fighting you until they turn you back from your faith, if they can. The works of those from among you who turn back from their faith and die in a state of disbelief shall be vain in this world and the next. These are the inmates of the fire, therein shall they abide (2:218).