Islam allows for self-defense when faced with imminent danger or harm. If someone is actively attacking or threatening you, it may be permissible to use necessary force to protect yourself. However, this should be done with the intention of preserving your safety and not out of anger or revenge. Islam promotes restraint and avoiding unnecessary harm even in self-defense.