The Messenger of Allah ﷺ sent us on a military expedition to the Huraqat. They became aware of our approach and fled, but we caught up with one man. When we closed in on him, he said, "There is no god but Allah." Yet we struck him down and killed him.I mentioned this to the Prophet ﷺ, and he said, "Who will defend you against 'There is no god but Allah' on the Day of Resurrection?"I said, "Messenger of Allah, he only said it out of fear of the weapon."He replied, "Did you split open his heart to know whether he said it for that reason or not? Who will defend you against 'There is no god but Allah' on the Day of Resurrection?"He kept repeating it until I wished I had not embraced Islam until that very day.
حدثنا الحسن بن علي وعثمان بن أبي شيبة المعنى قالا حدثنا يعلى بن عبيد عن الأعمش عن أبي ظبيان
بعثنا رسول الله ﷺ سرية إلى الحرقات فنذروا بنا فهربوا فأدركنا رجلا فلما غشيناه قال لا إله إلا الله فضربناه حتى قتلناه فذكرته للنبي ﷺ فقال من لك بلا إله إلا الله يوم القيامة فقلت يا رسول الله إنما قالها مخافة السلاح قال أفلا شققت عن قلبه حتى تعلم من أجل ذلك قالها أم لا من لك بلا إله إلا الله يوم القيامة فما زال يقولها حتى وددت أني لم أسلم إلا يومئذ
Muslim narrated it in the Book of Faith, Chapter on the prohibition of killing a disbeliever after he has said "there is no god but Allah," hadith no. 96, from the narration of Amash. Bukhari narrated it in the Book of Blood Money, Chapter "Whoever revives it..." etc., hadith no. 6872, from the narration of Abu Dhubyan Husayn bin Jundab, with the same wording.