Is it permissible to slaughter an animal with the intention of offering a sacrifice?
Question

                I have been married for four years and have not been blessed with children. Praise be to Allaah, I have recently heard the news that my wife is pregnant, and on my father’s advice I slaughtered two animals (as a sacrifice) and distributed the meat among needy Muslims, purely for the sake of Allaah on behalf of myself and my wife. What is the Islamic ruling on that? May Allaah reward you with good.
Praise be to Allah.
    If this sacrifice and feeding the needy was done as an act of 
    thanksgiving to Allaah, then it is permissible, for feeding people is a way 
    of doing good to people, and Allaah loves those who do good. 

    But if your sacrifice was aimed at warding off evil and 
    bringing about  good, then it is not permissible. This is what is well-known 
    among people when the word “sacrifice” (fadw) is used, because they 
    think that by doing this they will ward off evil and bring about good, so 
    they do this when accidents or sickness happen to them or their loved ones. 

    In Islam, sacrifice is not a means of warding off that which 
    has been decreed by Allaah, whether good or bad. 

    Shaykh ‘Abd al-‘Azeez ibn Baaz (may Allaah have mercy on him) 
    was asked about slaughtering an animal when a building is completed or 
    halfway through building. He said: 

    This action is subject to further examination. If the 
    intention behind the sacrifice is to protect oneself against the jinn or 
    some other intention by which the owner of the house intends to achieve 
    something, such as keeping it or its occupants safe, this is not 
    permissible, and it is a kind of bid’ah (innovation). If it is done for the 
    jinn then it is major shirk, because it is an act of worship done for 
    someone other than Allaah. 
But if it is done as an 
    act of thanksgiving for a blessing that Allaah has bestowed, such as 
    reaching the roof or completing the house, so the person gathers his 
    relatives and neighbours and invites them to this feast, there is nothing 
    wrong with this. This is what many people do as an act of thanksgiving for a 
    blessing from Allaah, as He has enabled them to build a house and live in it 
    instead of renting. Similar to this is what some people do when they come 
    back from a journey, and they invite their relatives and neighbours as an 
    act of thanksgiving to Allaah for their safe arrival.  When the Prophet  
    (peace and blessings of Allaah be upon him) came back from a journey he 
    would sacrifice a camel and invite the people to eat. (Narrated by al-Bukhaari, 
    3089). 

    Majmoo’ Fataawa al-Shaykh Ibn Baaz, 
    5/388. 

    Shaykh Muhammad al-Saalih ibn ‘Uthaymeen (may Allaah have 
    mercy on him) said: 
What some people do when 
    they move into a new house and slaughter an animal and invite their 
    neighbours and relatives is fine so long as it is not accompanied by any 
    corrupt beliefs, as is done in some places where, when a person moves into a 
    new house, the first thing he does is to bring a sheep and slaughter it on 
    the threshold so that the blood will fall onto it, and they say that this 
    will prevent the jinn from entering the house. This is a corrupt belief 
    which has no basis in Islam. But if a person slaughters it as an expression 
    of joy and happiness, there is nothing wrong with that. 

    Al-Sharh al-Mumti’, 7/550, 551. 

    And Allaah knows best.