That (general directive) entails killing every polytheist, monk or otherwise. The Prophet’s—peace and blessings be upon him—statement, “I have been commanded to fight the people until they declare, ‘There is no god but Allah,’” conveys the same.
As for the narrations that call for sparing these categories, they include the report transmitted by Dāwūd ibn al-Ḥuṣayn, from ʿIkrimah, from Ibn ʿAbbās: whenever the Prophet—ﷺ—dispatched an army he would say, “Do not kill the inhabitants of hermitages.”
Another is the ḥadīth reported by Anas ibn Mālik from the Prophet—ﷺ—who said, “Do not kill a decrepit old man, a young child, or a woman, and do not act treacherously with the spoils.” Abū Dāwūd collected it.
Mālik also related from Abū Bakr that he said, “You will encounter people who claim to have devoted themselves to Allah; leave them to what they have devoted themselves to,” and in the same directive, “Do not kill any woman, child, or very aged man.”
It appears that the strongest reason for the scholarly disagreement on this issue is the seeming opposition between the Almighty’s words,
“Fight in the way of Allah those who fight you, but do not transgress; surely Allah does not love the transgressors” (al-Baqarah 2:190),
and His words,
“When the sacred months have elapsed, slay the polytheists wherever you find them” (al-Tawbah 9:5).
Those who regarded the latter verse as abrogating the former—on the grounds that fighting was initially permitted only against aggressors—treated it as entirely general. Those who considered “Fight in the way of Allah those who fight you” to remain operative, and to cover these non-combatant groups, excluded them from the sweep of the other verse.
Al-Shāfiʿī argued from the ḥadīth of Samurah, in which the Messenger of Allah—ﷺ—said, “Kill the elders among the polytheists and spare their youths.” In his view, the cause that renders killing permissible is disbelief itself, and that cause must be applied consistently to all unbelievers.
As for those who held that farmers are not to be killed, they based their opinion on the report of Zayd ibn Wahb: “A letter reached us from ʿUmar—may Allah be pleased with him—in which he wrote: ‘Do not embezzle [the spoils], do not act treacherously, do not kill an infant, and fear Allah with regard to the tillers of the land.’”
Likewise, the report of Rabāḥ ibn Rabīʿah forbids killing an idolatrous hired laborer. He relates that he accompanied the Messenger of Allah—ﷺ—on a campaign; Rabāḥ and the Companions passed by a slain woman, whereupon the Messenger—ﷺ—stopped beside her and said, “She was not one who would fight!” He then looked at the faces of the people and said to one of them, “Go …” (the narration continues).