The Muslim law on the subject is as follows:-
“If any person draw a sword upon a Muslim he (the Muslim) is at liberty to kill him in self-defence, because the Prophet has said, ‘He who draws a sword upon a Muslim renders his blood liable to be shed with impunity’; and also, because a person who thus draws a sword is a rebel, and guilty of sedition; and it is lawful to slay such, God having said, in the Qur’an, ‘Slay those who are guilty of sedition, to the end that it may be prevented.’ Besides, it is indispensably requisite that a man repel murder from himself and as, in the present instance, there is no method of effecting this but by slaying the person, it is consequently lawful so to do. If however, it be possible to effect the self-defence without slaying the person, it is not lawful to slay him. It is written in the Jama Sagheer (al-Jani’u ‘s-Saghir), that if a person strike at another with a sword, during either night or day, or lift a club against another in the night in a city, or in the day-time in the highway out of the city; and the person so threatened kill him who thus strikes with the sword, or lifts the club, nothing is incurred; because, as striking with a sword affords no room for delay or deliberation, it is in this case necessary to kill the person in order to repel him; and although, in the case of a club, there be more room for deliberation, yet in the night-time assistance cannot be obtained, and hence the person threatened is in a manner forced, in repelling the other’s attack, to kill hem. (And so likewise where the attack is made during the day-time in the highway, as there assistance cannot readily be obtained). Where, therefore, a person thus slays another, the blood of the slain is of no account. If a lunatic draw a sword upon a person, and the person slay him, the fine of blood is due from his property, and does not fall upon his Akilas (Aqilah). As-Shafi’i maintains that nothing whatever is incurred in this instance. In the same manner also, if an infant draw a sword and make an attack upon a person, or if an animal attack anyone, and the person so attacked slay the infant, or the animal, a fine is due on account of the infant, or the value on account of the animal, according to Abu Hanifah, but not according to ash-Shafi’i.
“If a person draw a sword upon another, and strike him, and then go away, and the person struck, or any other, afterwards kill this person, he is liable to retaliation. This is where the striker retires in such a way as indicates that he will not strike again, for as, upon his so retiring, he no longer continues an assailant, and the protection of his blood (which had been forfeited by the assault) reverts, retaliation is consequently incurred by killing him.
“If a person come in the night to a stranger, and carry off his goods by theft, and the owner of the goods follow and slay him, nothing whatever is incurred, the Prophet having said, ‘Ye may kill in preservation of your property.’ It is to be observed, however, that his is only where the owner cannot recover his property but by killing the thief; for if he know that upon his calling out the thief would relinquish the goods, and he notwithstanding neglect calling out, and slay him, retaliation is incurred upon him, since he in this case slays the person unrighteously.” (Hidayah, vol. iv. p. 291.)
Based on Hughes, Dictionary of Islam