Sayyiduna Abdullah bin Abbas (may Allah be pleased with them both) narrates: The Messenger of Allah (peace and blessings be upon him) sent out a small detachment in which was Sayyiduna al-Miqdad bin al-Aswad (may Allah be pleased with him). When they reached the enemy people, they found them dispersed, except for one man who had much wealth; he stayed where he was and did not go anywhere. He said: "I bear witness that there is no god but Allah." Sayyiduna al-Miqdad (may Allah be pleased with him) lunged at him and killed him. One of his companions said: "Did you kill a man who said 'La ilaha illallah (There is no god but Allah)'? By Allah, we will certainly mention this to the Prophet (peace and blessings be upon him)." So when they came to the Prophet (peace and blessings be upon him), they said: "O Messenger of Allah! A man bore witness that there is no god but Allah, but al-Miqdad killed him." He (peace and blessings be upon him) said: "Call al-Miqdad to me." Then he said: "O Miqdad! Did you kill a man who said 'There is no god but Allah'? Then what will become of you before (the claim of) 'There is no god but Allah'?" Sayyiduna Ibn Abbas (may Allah be pleased with them both) said: Then Allah Almighty revealed this verse: "O you who believe! When you go forth in the cause of Allah, verify, and do not say to the one who offers you peace, 'You are not a believer,' seeking the goods of the life of this world. With Allah are abundant spoils. You were like that before, then Allah conferred His favour upon you." And the Messenger of Allah (peace and blessings be upon him) said: "He was a believing man who was concealing his faith while living with a disbelieving people, and you killed him, while you yourself used to conceal your faith in Makkah before this."
Imam al-Bukhari (may Allah have mercy on him) narrated the last part of it in mu'allaq form and said: Habib bin Abi Amrah narrated from Sa'id (may Allah have mercy on him), from Sayyiduna Ibn Abbas (may Allah be pleased with them both), that the Prophet (peace and blessings be upon him) said to Sayyiduna al-Miqdad (may Allah be pleased with him): "When a believing man was concealing his faith among a disbelieving people, then he made his faith known, you killed him? While you yourself used to conceal your faith in Makkah before this."
Mu'awiyah bin Amr narrated it in abridged form from Abu Ishaq al-Fazari, from Sufyan, from Habib, from Sa'id bin Jubayr (may Allah have mercy on him), that he said: "Sayyiduna al-Miqdad (may Allah be pleased with him) went out (on the expedition)," and he did not mention Sayyiduna Ibn Abbas (may Allah be pleased with them both) in it.