Praise be to Allah.
A woman who is being forced to commit zinaa [unlawful sexual activity] is obliged to defend herself and should not give in even if she kills the one who wants to do that to her. This self-defence is waajib (obligatory), and she is not at fault if she kills the one who wants to force her into zinaa. Imaam Ahmad and Ibn Hibbaan reported that the Prophet (peace and blessings of Allaah be upon him) said: Whoever is killed defending his property is a shaheed (martyr), whoever is killed defending himself is a shaheed, whoever is killed defending his religion is a shaheed, and whoever is killed defending his family is a shaheed. In the commentary on this hadeeth it says: whoever is killed defending his family is a shaheed refers to the one who defends the honour of his wife and female relatives.
If a man is obliged to defend his wife and fight off the one who wants to rape her even if this leads to his own death then this obligation applies even more to the woman herself, who must defend herself and not give in to the aggressor who wants to violate her honour, even if she is killed, because if she is killed she will also be a shaheedah, just as her husband will be a shaheed if he was killed defending her honour. Shahaadah (martyrdom, the status of shaheed) is a high status which is only achieved by the one who dies in the way of obedience to Allaah and that which He loves, which indicates that Allaah loves this kind of defence, a mans fighting to defend his wifes honour and a womans fighting to defend herself. But if she is unable to defend herself, and the evil aggressor overpowers her and rapes her by force, then she should not be subjected to any punishment (hadd or tazeer); rather, the punishment should be carried out on the evil aggressor.
It says in al-Mughni by Ibn Qudaamah al-Hanbali: Concerning a woman who was pursued by a man, and she killed him to protect herself, Ahmad said: If she knew that he wanted [to rape] her, and she killed him to protect herself, then she is not at fault. Ahmad mentioned the hadeeth which al-Zuhri reported from al-Qaasim ibn Muhammad, from Ubayd ibn Umayr, in which it said that a man had visitors from [the tribe of] Hudhayl, and he wanted [to rape] a woman, so she threw a rock at him and killed him. Umar said, By Allaah, there is no diyah for him ever i.e., she did not have to pay the blood money for him. If it is permissible to defend one's money, which one can give away, then a woman defending and protecting herself and her honour which cannot be given away, is clearly more permissible than a man defending his money. If this is clear, then she is obliged to defend herself if she can, because letting someone overpower her [rape her] is haraam, and by not defending herself, she lets him overpower her. [al-Mughni, 8/331]
And Allaah knows best. Al-Mufassal fi Ahkaam al-Marah, 5/42-43.
Ibn al-Qayyim (may Allaah have mercy on him) said in al-Turuq al-Hukmiyyah, 18: (Section) A woman who had committed zinaa was brought to Umar ibn al-Khattaab (may Allaah be pleased with him), and he asked her about it and she admitted it, so he commanded that she should be stoned. Ali said: Maybe she had a reason. So he said to her, What made you do that? She said, I had a partner who shared livestock with me; his camels had water and milk, and mine had none. I got thirsty, so I asked him to give me something to drink, but he refused unless I let him have his way with me. I refused three times, but I was so thirsty that I thought I was going to die, so I gave him what he wanted, and he gave me something to drink. Ali said: Allaahu akbar! But if one is forced by necessity without wilful disobedience nor transgressing due limits, then there is no sin on him. Truly Allah is Oft-Forgiving, Most Merciful. [al-Baqarah 2:173 interpretation of the meaning].
In Sunan al-Bayhaqi it says: From Abu Abd al-Rahmaan al-Sulami, who said: A woman was brought to Umar who had been extremely thirsty, and had passed by a shepherd and asked him to give her something to drink; he had refused to give her something to drink unless she let him have his way with her. [Umar] consulted with the people as to whether he should have her stoned. Ali said, She was forced to do it. I think you should let her go. So he did so. I say: this is what should be done. If a woman is in desperate need of food and drink from a man, which he will not give her unless she lets him have his way with her, and she is scared that she will die without them, so she lets him have his way with her, then she is not to be punished. If it were asked, is it permissible for her in this situation to let him have his way with her, or does she have to suffer [her hunger and thirst] with patience, even if she dies? The answer is that her case is like that of a woman who is forced to commit zinaa, to whom it is said, Either you let me have my way with you, or I will kill you. The woman who is forced to do this should not be punished; she can save herself from being killed in this manner, but if she bears it (i.e., being killed) with sabr (patience), this is better for her. (But she does not have to put up with with being killed). And Allaah knows best.