Abu Hurairah (May Allah be pleased with him) reported:
The Messenger of Allah (ﷺ) sent an espionage mission of ten men under the leadership of 'Asim bin Thabit Al-Ansari (May Allah be pleased with him). They proceeded till they reached Al-Had'ah, a place between 'Usfan and Makkah and the news of their arrival reached a section of the tribe of Hudhail, called Banu Lihyan. About one hundred men, who were all archers, hurried to follow their tracks. When 'A sim and his companions came to know of their pursuers, they took refuge in a safe place. The infidels encircled them and said to them: "Come down and surrender, and we promise and guarantee you that we will not kill anyone of you." 'Asim bin Thabit (May Allah be pleased with him) said: "By Allah! I will not come down to be under the protection of disbelievers. O Allah! convey this news to our Prophet (ﷺ)." Then the infidels shot arrows at them till they killed 'Asim. Three men came down relying on their promise and covenant. They were Khubaib, Zaid bin Ad-Dathinah and another man. When the disbelievers captured them, they tied them up with the strings of their bows. The third of the captives said: "This is the beginning of first betrayal. By Allah! I will not go with you. I have a good example in these (martyrs)." So they dragged him and tried to compel him to accompany them, but he refused. At last they killed him. They took Khubaib and Zaid bin Ad- Dathina with them and sold them as slaves in Makkah. This incident took place after the battle of Badr.Khubaib was bought by the sons of Al-Harith bin 'Amir bin Naufal bin 'Abd Manaf. It was Khubaib who had killed Al-Harith in the battle of Badr. Khubaib remained a prisoner with those people for a few days till the sons of Al-Harith resolved to kill him.When Khubaib (May Allah be pleased with him) got wind of this plot, he borrowed a razor from one of Al- Harith's daughters in order to remove his pubic hair. Her little son crawled towards Khubaib because of her carelessness. Later on, she saw her son on his thigh and the razor was in his hand. She got scared so much that Khubaib noticed the agitation on her face and said: "Are you afraid that I will kill him? No, I will never do that." She later remarked (after Al-Khubaib got martyred): "By Allah! I never saw a prisoner better than Khubaib." She added: "By Allah! I saw him once eating of a bunch of grapes in his hand while he was chained and there was no such fruit at that time in Makkah. Probably it was a boon which Allah bestowed upon Khubaib."When they took him out of the Haram of Makkah to kill him outside its boundaries, Khubaib requested them to let him offer two Rak'ah of voluntary prayer. They allowed him and he offered two Rak'ah prayer. Then he said: "Had I not apprehended that you would think that I was afraid of death, I would have prolonged the prayer. O Allah! Count their number; slay them one by one and spare not one of them." He then recited these poetic verses:'I do not care how they kill me as long as I get martyred in the Cause of Allah as a Muslim. I received my death for Allah's sake. If Allah so desires, He will bless, the amputated limbs of the torn body.'Then the son of Al-Harith killed him. It was Khubaib who set the tradition for any Muslim sentenced to death in captivity to offer two Rak'ah of voluntary prayer. On that day the Messenger of Allah (ﷺ) informed his Companions of the martyrdom of Khubaib. Later on, when some disbelievers from Quraish were informed that 'Asim had been martyred, they sent some people to fetch a significant part of his body to ascertain his death. (This was because) 'Asim had killed one of their chiefs. So Allah sent a swarm of wasps, resembling a shady cloud, to hover over the body of 'Asim and to shield him from their messengers, and thus they could not cut off anything from his body.[Al- Bukhari].
App reference: Book 17, Hadith 45
Arabic/English book reference: Book 17, Hadith 1509