عَنْ أَبِي هُرَيْرَةَ رَضِيَ اللَّهُ عَنْهُ قَالَ سَمِعْتُ رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَآلِهِ وَسَلَّمَ يَقُولُ الْوَلَدُ لِصَاحِبِ الْفِرَاشِ وَلِلْعَاهِرِ الْحَجَرُ
Sayyiduna Abu Hurairah (may Allah be pleased with him) narrates that I heard the Noble Prophet (peace and blessings be upon him) say: The child will belong to the owner of the bed, while the adulterer will receive stones.
Brief Explanation
Benefits: … The child born from a married woman will be considered as belonging to the husband, and similarly, the child born from a slave woman (bondwoman) will be considered as belonging to her master, as long as the husband or the master does not deny (paternity) on the basis of some evidence. This is because the matter of a child being legitimate or illegitimate is hidden, and reaching its reality is a difficult affair.