A: Narrated Abdullah ibn Amr ibn al-‘As (RadhiyAllahu Anhu): A man got up and said: Apostle of Allah, so-and-so is my son; I had illicit intercourse with his mother in the pre-Islamic period. The Apostle of Allah (Sallallahu Alaihi Wasallam) said: There is no unlawful claiming of paternity in Islam. What was done in pre-Islamic times has been annulled. The child is attributed to the one on whose bed it is born, and the fornicator is deprived of any right. (Abu Dawud, Kitab Talaq)
Narrated Abdullah ibn Abbas (RadhiyAllahu Anhu): The Prophet (Sallallahu Alaihi Wasallam) said: There is no prostitution in Islam. If anyone practised prostitution in pre-Islamic times, the child will be attributed to the master (of the slave-woman). He who claims his child without a valid marriage or ownership will neither inherit nor be inherited. (Abu Dawud, Kitab Talaq)
Narrated Abdullah ibn Amr ibn al-‘As (RadhiyAllahu Anhu): The Prophet (Sallallahu Alaihi Wasallam) decided regarding one who was treated as a member of a family after the death of his father, to whom he was attributed when the heirs said he was one of them, that if he was the child of a slave-woman whom the father owned when he had intercourse with her, he was included among those who sought his inclusion, but received none of the inheritance which was previously divided; he, however, received his portion of the inheritance which had not already been divided; but if the father to whom he was attributed had disowned him, he was not joined to the heirs.
If he was a child of a slave-woman whom the father did not possess or of a free woman with whom he had illicit intercourse, he was not joined to the heirs and did not inherit even if the one to whom he was attributed is the one who claimed paternity, since he was a child of fornication whether his mother was free or a slave. (Abu Dawud, Kitab Talaq)
From the above Ahadith we understand that the right of paternity will always be for the person to whom the mother of the child is married. Hence, paternity will not be established with the fornicator. If the woman is unmarried, the child will only be attributed to her. If the woman is married but was impregnated by a third party, then the child will be attributed to the mother’s husband.
The Fuqaha (jurists) mentions that if one was to marry a woman whom one had impregnated and after six months the child is born then the child will be considered legitimate and will be attributed to the father and will inherit from him. If the child is born before six months then it will be known as a child of Zina (illegitimate) and will not be attributed to the father but will be attributed to the mother and will inherit from her.
The maximum gestation period is two years, according to Imam Abu Hanifah (Rahmatullahi Alaih), and four years according to the other Imams i.e. Imam Shafi’ and Hanbal (Rahmatullahi Alaihima), and five years according to Imam Malik (Rahmatullahi Alaih). However, there is Ijma’ (concensus) with the minimum gestation period, that is six months.
Therefore, on the basis of this Ijma’ a child born before six months will be considered illegitimate.
(Raddul Muhtar Vol.2 Pg.676, Qudoori Pg.241, Al Hidayah, Ahsanul Fataawa Vol.5 Pg.456, Al Fiqhul Islami Wa Adillatuhu Vol.7 Pg.676)