Hadith no. 2682 (below) is a repeat. Read it here.
Volume 4, Book 52, Number 285 :
Narrated by Jubair (who was among the captives of the Battle of Badr)
“I heard the Prophet reciting ‘Surat-at-Tur’ in the Maghrib prayer.”
Volume 4, Book 52, Number 286 :
Narrated by Salama bin Al-Akwa
“An infidel spy came to the Prophet while he was on a journey. The spy sat with the companions of the Prophet and started talking and then went away. The Prophet said (to his companions), ‘Chase and kill him.’ So, I killed him.” The Prophet then gave him the belongings of the killed spy (in addition to his share of the war booty).”
The spy is the one who spies on the Muslims and transmits information to their enemies.
The evidence for that is the report narrated by al-Bukhaari (3007) and Muslim (2494) which says that Haatib ibn Abi Balta’ah wrote to some of the mushrikeen in Makkah telling them some information about the Messenger of Allaah (peace and blessings of Allaah be upon him). The Messenger of Allaah (peace and blessings of Allaah be upon him) said: “O Haatib, what is this?” He said, “O Messenger of Allaah, do not hasten to judge me. I was a man closely connected to Quraysh, but I did not belong to this tribe, while the other Muhaajireen with you had their relatives in Makkah who would protect their families and property. So I wanted to make up for my lack of blood ties to them by doing them a favor so that they might protect my family. I did not do this because of disbelief or apostasy nor out of preferring kufr (disbelief) to Islam.” The Messenger of Allaah (peace and blessings of Allaah be upon him) said, “He has told you the truth.” ‘Umar said, “O Messenger of Allaah! Let me chop off the head of this hypocrite!” The Messenger of Allaah (peace and blessings of Allaah be upon him) said: “He was present at the battle of Badr, and you do not know, perhaps Allaah looked at the people of Badr and said, ‘Do whatever you like, for I have forgiven you.’”
The point in this hadeeth is that the Prophet (peace and blessings of Allaah be upon him) agreed with ‘Umar that Haatib deserved to be executed for this action, but the Prophet (peace and blessings of Allaah be upon him) told him that there was a reason why he should not be killed, which is that he was one of those who was present at the battle of Badr.
Ibn al-Qayyim said in Zaad al-Ma’aad (2/115) concerning the hadeeth of Haatib ibn Abi Balta’ah:
This was quoted as evidence by those who do not think that the Muslim spy should be killed, such as al-Shaafa’i, Ahmad and Abu Haneefah (may Allaah have mercy on them). And it was quoted as evidence by those who think that the spy should be killed, such as Maalik and Ibn ‘Aqeel among the companions of Ahmad, and others. They said: This is because the reason for not killing him was that he had been present at Badr. If being Muslim was the reason for not killing him, he would not have given a reason that is more specific, which is the fact that he had been present at Badr.
And he said elsewhere in Zaad al-Ma’aad (3/422):
The correct view is that execution of a spy depends on the opinion of the ruler; if executing him is in the Muslims’ interests, he should be executed, but if letting him live serves a greater interest, then he should be allowed to live. And Allaah knows best.