Praise be to Allah.
Undoubtedly what you have done, committing zina (adultery) when you were married, is a major sin. Because zina is a major sin, it is a serious matter when committed by those who are married. Hence the punishment for the unmarried person who commits zina is one hundred lashes, and the punishment for the married person whose marriage was consummated is stoning to death.
Although the sin that you have committed is so abhorrent to those who have a sound human nature and common sense, it does not mean that you cannot repent. Allaah rejoices over the repentance of sinners and accepts it from them.
Allaah says (interpretation of the meaning):
“Say: O ‘Ibaadi (My slaves) who have transgressed against themselves (by committing evil deeds and sins)! Despair not of the Mercy of Allaah, verily, Allaah forgives all sins. Truly, He is Oft‑Forgiving, Most Merciful”
Ibn Katheer (may Allaah have mercy on him) said:
This verse is a call to all sinners, kaafirs and others, to repent and turn to Allaah. It tells us that Allaah forgives all sins for the one who repents from them and gives them up, no matter what they are, and even if they are as many as the foam of the sea. End quote.
Tafseer Ibn Katheer (7/106).
We hope that your repentance is sincere, and includes regret for what you have done, and resolve not to commit the sin again after repenting.
As for whom the child is to be attributed to – he is to be attributed to your husband if he had consummated the marriage with you, because the Prophet (peace and blessings of Allaah be upon him) said: “The child is for the bed,” meaning that if a woman has gotten married to a man by means of the marriage contract and he has consummated the marriage with her, if she produces a child, then the child is to be attributed to her husband.
Shaykh Ibn Baaz (may Allaah have mercy on him) was asked about a married woman who had three children, and she became pregnant with a fourth child as the result of zina. Is it permissible for her to abort the foetus, or should she keep it? If she keeps it, should she tell her husband or not? And what should the husband do in this case?
He replied: It is not permissible for her to abort the foetus. What she has to do is repent to Allaah and not disclose this matter. The child belongs to her husband, because the Prophet (peace and blessings of Allaah be upon him) said: “The child belongs to the (marital) bed, and the adulterer gets nothing.” May Allaah set all our affairs straight. End quote.
Fataawa al-Shaykh Ibn Baaz (21/205).
This is the ruling stated in fatwas by the Standing Committee for Issuing Fatwas. We have quoted their fatwas in the answer to question no. 95024.
And Allaah knows best.