Answer
In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
In this fatwa:
1- All sexual relations outside marriage are strictly forbidden in Islam.
2- A child born as a result of an illegitimate relationship suffers no adverse discrimination on account of his parents’ sin.
3- Such a child cannot prove his filiation to his father unless the latter asserts his paternity. In this case, he can have a share in his father’s wealth.
Answering your question, Dar Al-Ifta Al-Misriyyah, states:
Sex outside marriage in Islam
As you realize, all sexual relations outside marriage are strictly forbidden in Islam. This is part of the very serious view Islam takes of morality. Although the punishments prescribed for adultery and fornication differ in severity, with the severer punishment reserved to married adulterers, the fact that a punishment has been prescribed by God the Almighty for such actions is more than enough to indicate their gravity.
However, a basic principle in Islamic justice is that no one bears the blame for another’s fault. A child born as a result of an illegitimate relationship suffers no adverse discrimination on account of his parents’ sin.
However, such a child cannot prove his filiation to his father unless the latter asserts his paternity. If the father makes such an acknowledgment, he is not asked about the circumstances of the birth of his child; his statement is accepted.
Take for example the case of a young couple who get married after the woman becomes pregnant.
The legitimacy of their first child is a question that no one will raise since they have taken the right steps to bring the child into their family home. The child will inherit from his or her parents, along with their brothers and sisters, according to Islamic law, which gives a son twice the share of a daughter.
Almighty Allah knows best.
Source: Dar al-Ifta al-Misriyyah