All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His Slave and Messenger.
First of all, we thank and praise Allaah Who guided you to Islam and we ask Him to make you firm and steadfast in His Religion until the Day you meet Him. We advise you to seek beneficial knowledge, perform good deeds and befriend righteous and pious women, as these are the best things that help a Muslim woman remain steadfast in her religion. May Allaah allow us to do good and make us firm in the Firm Word in this life and the Hereafter [the "firm word" means the testimony that there is no god worthy of worship except Allaah and that Muhammad is the Messenger of Allaah].
It is permissible for you to ask your husband for divorce because of harm. For information on the legitimate reasons for a wife to ask for divorce, please refer to Fatwa 165253.
If you gave birth to this child after six months or more of marriage, then it bears the name of your ex-husband, and he has no right to deny it except through Li’aan (i.e. when a husband accuses his wife of Zina [adultery] and each of the spouses makes an oath that he/she is truthful in his claim and then asks Allaah to curse the one who is lying). For more benefit, kindly refer to Fataawa 200749 and 193277.
Abu Bakrah narrated that the Prophet said: “The child is for the owner of the bed (i.e. the husband).” [Muslim] Please refer to Fataawa 84301 and 86773.
A child's lineage is not something that can be manipulated or bargained so as to be traded for divorce, so this child bears the name of the father whether he agrees or not. The father is responsible for this child before Allaah. Ibn ‘Umar said: "I heard the Prophet saying: “Each of you is a shepherd (guardian) and each of you is responsible for his herd … a man is a shepherd in his house and is responsible for his herd ...” [Al-Bukhari and Muslim]
However, if divorce is made in return for the renouncement of some rights or in return for the mother assuming the expenses of the child, then there is nothing wrong with that. Shaykh Ibn Taymiyyah said: “If [the husband] grants her Khul’ in return for her renouncing her rights over him, and she takes the child under her guardianship, and she does not ask him for financial support for the child, then this is correct according to the majority of the scholars, like Maalik and Ahmad - in his well-known opinion - and others. Also, according to the majority of the scholars, Khul’ is valid in return for something that does not yet exist but whose existence is expected, like the produce of one her (the wife's) trees or offspring of one of her slave-girls. As regards financially supporting her during pregnancy and nursing, and financially supporting the child, then the basis of its existence and its being permissible already exists [in other words, she may renounce such financial support with even more certainty]. The same thing applies if she says to her husband, 'divorce me and I render you free from all my rights over you' and 'I take the child to sponsor it and I declare you free from financial support for it', and other similar matters that indicate the objective.” [End of quote]
If your husband was the reason that you asked for divorce because he wronged or harmed you, then it is forbidden for him to accept compensation. Ibn al-Munthir said: “The scholars have unanimously agreed that it is forbidden for the husband to take her property [in compensation] unless she is the one who is disobedient and the one who spoilt the relationship.” For more benefit, please refer to Fatwa 131953.
His statement that ‘you got pregnant before marriage’: if by this he is accusing you of Zina (adultery or fornication), then this is a very serious matter; in fact, it is a form of slander; so if he does not bring forth evidence for this, he deserves the Hadd (the corporal punishment determined by the Islamic Law) for slander, which is eighty lashes. Allaah says (what means): {And those who accuse chaste women and then do not produce four witnesses — lash them with eighty lashes and do not accept from them testimony ever after. And those are the defiantly disobedient.} [Quran 24:4]
Finally, it should be noted that the husband is commanded in Islam to treat his wife kindly, pursuant to the saying of Allaah (which means): {And live with them in kindness. For if you dislike them — perhaps you dislike a thing and Allaah makes therein much good.} [Quran 4:19]
Your husband beating you is in opposition to this Divine directive and it is a sign of vileness and bad moral conduct. Please refer to Fatwa 88304.
Allaah Knows best.