The following situations describe when the life of a kafir is sacred and forbidden to take.
If a kafir does not fall into one or more of these categories then may their life rightfully be taken?
Situations when a kafir's life is sacred:
has become the subject of the Islamic state by agreeing to pay the jizyah tax.
قاتلوا ... حتى يعطوا الجزية
Fight ... until they give the jizyah
وإذا لقيت عدوك من المشركين فادعهم إلى ثلاث خصال أو خلال فأيتهن ما أجابوك فاقبل منهم وكف عنهم ثم ادعهم إلى الإسلام ... فإن هم أبوا فسلهم الجزية فإن هم أجابوك فاقبل منهم وكف عنهم
When you meet your enemies who are polytheists, invite them to three courses of action. If they respond to any one of these, you also accept it and withhold yourself from doing them any harm. Invite them to (accept) Islam; ... If they refuse to accept Islam, demand from them the Jizya. If they agree to pay, accept it from them and hold off your hands.
— Muslim
has a treaty with the Muslims
وإن جنحوا للسلم فاجنح لها وتوكل على الله
And if they incline to peace, then incline to it [also] and rely upon Allah
من قتل معاهدا لم يرح رائحة الجنة وإن ريحها توجد من مسيرة أربعين عاما
Whoever killed a person having a treaty with the Muslims, shall not smell the smell of Paradise though its smell is perceived from a distance of forty years.
— Bukhari
has been granted aman (assurance of safety) by any Muslim
وإن أحد من المشركين استجارك فأجره حتى يسمع كلام الله ثم أبلغه مأمنه ذلك بأنهم قوم لا يعلمون
And if any one of the polytheists seeks your protection, then grant him protection so that he may hear the words of Allah . Then deliver him to his place of safety. That is because they are a people who do not know.
ذمة المسلمين واحدة يسعى بها أدناهم
The asylum granted by any Muslim is to be secured by all the Muslims, even if it is granted by one of the lowest social status among them
does not participate in fighting e.g. women, children, farmers, laborers, priests, disabled or elderly people etc.
وقاتلوا في سبيل الله الذين يقاتلونكم ولا تعتدوا إن الله لا يحب المعتدين
Fight in the way of Allah those who fight you but do not transgress. Indeed. Allah does not like transgressors.