She got pregnant from him after the traditional ceremony and before the official ceremony
Question

                The imam of a mosque proposed marriage to a woman, on the basis that they would be engaged for five years, and he did the marriage contract with her before a number of people, but before he announced his marriage to her and before the marriage was officially registered, he had intercourse with her without her family’s knowledge, and when he decided to announce the marriage with the daff (i.e., hold a wedding party) and register the marriage officially, she was pregnant and there were only three months left until the birth. 

My questions are: 

1- What is the ruling on his marriage and what is the ruling on the child who is born as a result?

2- Is the husband regarded as having done something haraam by doing this, or not?

3- What is the ruling on praying behind this imam?.
Praise be to Allah.Firstly: 
If the 
    marriage contract to which you refer met the conditions of proposal and 
    acceptance, and the presence of the woman’s wali (guardian) and two 
    witnesses, and was done with the woman’s consent, then this is a valid 
    marriage contract with all that that entails. The woman became his wife 
    thereby and it is permissible for her husband to be intimate with her, 
    including intercourse. But if he refrained from intercourse that would have 
    been better, in accordance with custom and so as to avoid the negative 
    consequences that result from that, such as suspicion and so on, especially 
    since the marriage was not registered officially. 
The child 
    who results from this marriage is legitimate and is to be named after his 
    father, because it is a valid marriage. See also question no.
    75026. 
But if the 
    marriage did not fulfil the conditions, such as if there was no wali, then 
    it is an invalid marriage according to the majority of fuqaha’, but the 
    child should still be attributed to his father. 
The one who 
    did this marriage contract although he knew that it was haraam, and had 
    intercourse after that, is a zaani (fornicator, adulterer) and is judged to 
    be a faasiq (rebellious evildoer) unless he repents and become righteous.  
Shaykh 
    al-Islam Ibn Taymiyah said in al-Fataawa al-Kubra (3/326): Whoever 
    has intercourse with a woman in an invalid marriage believing that she is 
    his wife, his child from her is to be attributed to him, according to the 
    consensus of the Muslims. End quote. 
Secondly: 
With regard 
    to praying behind him, such prayers are valid, and what has happened does 
    not undermine his religious commitment and he is not judged to be a faasiq 
    (rebellious evildoer) because of it, because if the first marriage contract 
    was valid, there is no problem and that does not undermine his religious 
    commitment. But if it was invalid – such as if it was done without a wali – 
    and it seems that he did that believing it to be permissible, then he is not 
    sinning and he is not judged to be a faasiq because of that.  
But this 
    imam made a mistake by hastening to consummate the marriage before 
    announcing the marriage and registering it officially, because that opens 
    the door to gossip about him and his wife, and exposes him to talk. The one 
    who is in a position where he is an example for people –such as an imam, 
    teacher, mufti, qaadi and so on – should keep away from everything that may 
    impugn their dignity and open the door to doubt and suspicion about them. 
May Allaah 
    help us all to do that which He loves and which pleases Him. 
And Allaah 
    knows best.