A fatwa declaring that an out-of-wedlock child is 'illegal' according to Sharia and may thus be treated as a 'foreigner' to the impregnating Muslim father.
Raising child of Zina in Muslim environment .
Praise be to Allah, the Lord of the World; and blessings and peace be upon our Prophet Muhammad and upon all his Family and Companions.
We have already made it clear that this boy is a foreigner to this man, i.e. has no family relationship with him.
So, this boy should be treated like any other person alien to the family. He is not to be considered nor treated as a member of the man's family. But, if this man wants to spend on him, to financially support him, to see that he is educated and raised in a Muslim environment, he may do so as a good deed for Allah's sake, just as he may for any other person. However, he cannot be considered as a member of the family or as an heir. It may even be a good deed, which will be, rewarded Insha Allah. This is so, because if this boy is educated according to Shariah and with a Muslim woman, he may become a good pious man. If, on the other hand he is left with a non-Muslim woman in this country of disbelief he will, most probably, become a non-believer.
So, it is lawful for you, and you are even recommended to look after this child and to educate him as to prevent him from going astray in this bad environment.
However, you should screen your wife and daughters from him as soon as he reaches the age of maturity.
Allah knows best.
Read it all here at Islam Web