Fight in God’s cause (only) those who wage war against you but do not commit aggression, for God does not love aggressors.* -- Q2:190
* This and the following verses lay down unequivocally that only self-defense (in the widest sense of the word) makes war permissible for Muslims. The defensive character of a fight “in God’s cause” – that is, in the cause of the ethical principles ordained by God – is, moreover, self-evident in the reference to “those who wage war against you”, and has been still further clarified in 22:39 –“permission [to fight] is given to those against whom war is being wrongfully waged” – which, according to all available Traditions, constitutes the earliest (and therefore fundamental) Qur’anic reference to the question of ‘just war’. That this early, fundamental principle of self-defense, as the only possible justification of war has been maintained throughout the Qur’an, is evident from 60:8 as well as from the concluding sentence of 4:91, both of which belong to a later period than the above verse.
Prophet said
On the day of the Battle of Badr the Messenger of God said, “When they attack you from the distance, (only then) shoot arrows at them; and do not take out the swords until they fall upon you --H: Abu Daud. N: Abu Osaid
In order to ensure that the Muslim armies do not transgress the limits the Holy Prophet of God always gave strict orders to the commanders to observe the laws and not to transgress the limits. (See second part of the introduction)