In The Name of Allaah, The Most Merciful, The Bestower of Mercy.
Abu Hurairah [may Allaah be pleased with him] reported: On the Day of Nahr at Mina, the Prophet [peace and blessings of Allaah be upon him] said, “Tomorrow we shall stay at Khaif Bani Kinana where the pagans had taken the oath of disbelief.” He meant (by that place) Al-Muhassab where the Quraish tribe and Banu Kinaanah concluded a contract against Banu Haashim and Banu Abdul-Muttalib or Banu Al-Muttalib that they would not intermarry with them or deal with them in business until they handed over the Prophet to them. [Saheeh al-Bukhaari. Hadeeth Number 1590]
Usaamah Bin Zayd [may Allaah be pleased with him] said, “I asked the Prophet [peace and blessings of Allaah be upon him] during his Hajj, ‘O Allah’s Messenger! Where will you stay tomorrow?’ He said, ‘Has Aqeel left for us any house?’ He then added, ‘Tomorrow we will stay at Khaif Bani Kinana, i.e. Al-Muhassab, where Quraihs (polytheists) took an oath of disbelief in that Banu Kinaanah allied with Quraish against Banu Hashim on the terms that they would not deal with the members of the tribe or give them shelter.” [Al-Bukhaari. Hadeeth Number 3058]
The incident mentioned in the above narrations took place when the Makkan polytheists had a meeting at a place called the valley of Al-Muhassab, where they established an alliance against Banu Haashim and Banu Al-Muttalib. They agreed not to have any business transactions with them, no marriage ties, no visits and no verbal communication with the Prophet [peace and blessings of Allaah be upon him] and those who aided him. So, Abu Taalib – the Prophet’s uncle who stood by him at the time – decided to move to a valley on the eastern suburbs of Makkah, then Banu Haashim and Banu Al-Muttalib also moved and they were all confined to a narrow passage. They remained in that situation for three years- from the 7th year of the Prophet’s Prophethood until 10th year. It was a very repressive embargo that brought extreme hardship, and in addition to this, the vile polytheists bought everything that reached Makkah in order that nothing reached Banu Al-Mutallib and Banu Haashim. The situation became so bad that they had to eat the leaves of trees and animal skins, and children constantly cried due to hunger. They had nothing besides very little provision that was sometimes delivered secretly by some people in Makkah who sympathised with them. During the sacred months when fighting was not permitted, they used to go and buy provisions, but the prices of goods were inflated so that they would not be able to afford it. However, this great hardship never stopped the Prophet [peace and blessings of Allaah be upon him] from calling to the truth, rather he used to go to the Ka‘bah and call people to Islam. By the grace of Allaah, the agreement between the polytheists ended in the 10th year of the Prophet’s Prophethood, because some of them could no longer bear to see their relatives in that situation. (1)
This is how the hostile Quraish treated the Messenger [peace and blessings of Allaah be upon him], but let us see how he treated them when he had the upper hand. Abu Hurairah [may Allaah be pleased with him] reported: “The Prophet sent a troop of fighters towards Najd and they brought a man from the tribe of Banu Haneefah who was called Thumamah bin Uthaal. He was then tied to one of the pillars of the Masjid. The Prophet went to him and said, “What have you got, O Thumama?” He replied,”I have got a good thought, O Muhammad! If you should kill me, you would kill a person who has already killed somebody, and if you should set me free, you would do a favor to one who is grateful, and if you want property, then ask me whatever wealth you want.” So, he was left till the next day when again the Prophet (ﷺ) said to him, “What have you got, O Thumama?” He said, “What I have already told you”. The Prophet (ﷺ) left him till the day after, and said to him again, “What have you got, O Thumama?” He said, “I have got what I told you. So the Prophet (ﷺ) said, “Set him free”. Then Thumamah) went to a garden of date-palm trees near to the Masjid, took a bath, entered the Masjid and then said, “I testify that None has the right to be worshipped except Allah, and also testify that Muhammad is His Messenger! By Allah, O Muhammad! There was no face on the surface of the earth most disliked by me than yours, but now your face has become the most beloved face to me. By Allah, there was no religion most disliked by me than yours, but now it is the most beloved religion to me. By Allah, there was no town most disliked by me than your town, but now it is the most beloved town to me. Your tropps arrested me (at the time) when I was intending to perform the `Umra. And now what do you think?” The Prophet (ﷺ) gave him good tidings of good in this world and the next, and ordered him to perform the `Umra. So when he came to Makkah, someone said to him, “You have become a Sabian?” He replied, “No! By Allah, I have submitted to Islam with Muhammad, Allaah’s Messenger. No, by Allah! Not a single grain of wheat will come to you from Yamamah unless the Prophet gives his permission.” [Al-Bukhaari – Number 4372]
So, the Prophet asked Thumaamah, “What have you got O Thumaamah?” He replied that he has good thoughts about the Prophet- Meaning, “You O Muhammad never oppress anyone, rather you are from those who pardon and do good”. So after he wa set free, he entered Makkah to perform Umrah and then pronounced the Talbilya and he was the first to enter Makkah in that manner, so Quraish grabbed him and said, “You have the audacity to do this to us”, and they wanted to kill him; then a person amongst the Quraish said, “Leave him, because you are in need of food from Yamaamah (i.e. from his land)”, so they released him. Then he said to them, “By Allah! Not a single grain of wheat will come to you from Yamamah unless the Prophet gives his permission.” Ibn Hishaam said, “Then Thumaamah returned to Yamaamah and prevented the Quraish from bringing any food to Makkah, so the Quraish wrote to the Prophet saying, “Indeed, you command people to keep good the ties of kinship”, so the Prophet wrote to Thumaamah to allow them to transport their food”.
The following benefits can be derived from this hadeeth:
[a] It is permissible for the Muslim ruler to imprison a kaafir prisoner of war in the Masjid due to some benefit; the permissibility of allowing a kaafir in the Masjid to drink water and listen to lectures.
[b] To treat a non Muslim prisoner of war kindly. Even though Thumaamah was a severe enemy, he was forgiven, and this shows the great virtue of forgiveness. When the Prophet saw that Thumaamaah was constantly having good thoughts, he pardoned him and this was a pardon in its right place and perfect circumstances. This also shows that the Muslim ruler can pardon a non-Muslin prisoner of war due to an overriding benefit or execute him based on an overriding benefit.
[c] In this hadeeth, we also learn that one should closely watch those prisoners of war who desire to accept Islam, especially those amongst them who – when they accept Islam, others will follow them.
[d] This hadeeth also teaches us that that the release or execution of a prisoner of war should be delayed. 
Indeed, brothers and sisters, the path of Muhammad is the only perfect path to follow in all affairs. We’ve witnessed the manner in which some of the armies – under the authority of some the leaders of the so called free world – treated prisoners of war in Iraq, Afghanistan and other places. The Kharijites (Al-Qaeda, ash-Sahbaab, ISIS and others) commit excess during wars and likewise some of the armies of the so called free world commit excess during wars; but look at how the Messenger and the companions treated Thumaamah [may Allaah be pleased with him]. Likewise, we find today that some leaders of the free world would impose sanctions against their enemies, even if such sanctions would harm other nations more than that the targeted nation. We hear how sanctions would lead to a shortage of wheat in African and Asian countries, even though they neither started a war nor wish to get involved; but look at how the Prophet even dealt with the hostile Quiraish when Thumaamah said to them, “By Allah! Not a single grain of wheat will come to you from Yamamah unless the Prophet gives his permission.” They wrote to the Messenger and pleaded with him, so he allowed them to freely carry their food, even though they were his staunchest enemies who sought to starve him and Banu Hashim; rather they even attempted to murder him. We ask Allaah to grant us the ability to follow the authentic Sunnah of the Messenger because that is the only path to salvation, as Allaah [The Exalted] stated:
[لَقَدۡ كَانَ لَكُمۡ فِيہِمۡ أُسۡوَةٌ حَسَنَةٌ۬ لِّمَن كَانَ يَرۡجُواْ ٱللَّهَ وَٱلۡيَوۡمَ ٱلۡأَخِرَۚ وَمَن يَتَوَلَّ فَإِنَّ ٱللَّهَ هُوَ ٱلۡغَنِىُّ ٱلۡحَمِيدُ – Certainly, there has been in them an excellent example for you to follow, for those who look forward to (the Meeting with) Allah (for the reward from Him) and the Last Day. And whosoever turn away, then verily, Allah is Rich (Free of all wants), Worthy of all Praise]. [Surah Al-Mumtahinah. Aayah 6]
[Ref 1: This incident is related both in Zaadul Ma’aadh 3/31 and Seerah Ibn Hishaam 1/350]
[Ref 2: Refer to “Fat-hul Baaree Sharh Saheeh Al-Bukhaari Vol 8. Pages 110-111 & Al-Hulalul Ibreeziyyah Min at-taleeqaat al-Baaziyyah Alaa Saheeh Al-Bukhaaree vol 3. Page 319]