Assalamualaikum ustaz. What is the ruling of a person who prays beside a child who has yet to be circumcised? Is his prayer invalidated if he comes in contact with the child?
Waalaikumussalam wrt. wbt.,
Alhamdulillah, praise and gratitude to Allah SWT for His countless blessings for us all. Praise and salutations to our beloved Prophet Muhammad PBUH, his family, companions, and all those who follow his footsteps until the Final day.
Basically, history has proven that children are brought to the mosque to teach them about prayer and learning. Furthermore, children should be brought to the mosque from an early age to cultivate their love for the mosque and congregational prayer in them.
Syeikh Dr Yusuf al-Qaradhawi said: The mosque institution also teaches us about equality. Where would equality be better showcased compared to when all Muslims are present in a mosque? The elderly sit by the children, minister beside ordinary workers, leaders together with the citizens and surely, there is no difference between them. 
Simply put, jurists are divided into two opinions on the issue of bringing children to the mosque. The following we share their opinions and arguments:
First: Children are prohibited from being brought to the mosque
Some Malikiyah, Hanabilah and Syafieyyah scholars are of the opinion that children who aren’t mumayyiz are prohibited or unallowed to enter the mosque. They based their opinion on a hadith that states:
From Muaz bin Jabal RA, the Prophet PBUH once said:
جَنِّبُوا مَسَاجِدَكُمْ صِبْيَانَكُمْ
“Keep your infants away from your mosques.” 
Second: Children are permissible to attend the mosque
This is the opinion of al-Hafiz Ibn Hajar al-Asqalani, Imam al-Syaukani, and others. They argued presenting a hadith from Abu Qatadah RA, he said:
رَأَيْتُ النَّبِيَّ صلى الله عليه وسلم يَؤُمُّ النَّاسَ وَأُمَامَةُ بِنْتُ أَبِي الْعَاصِ وَهِيَ ابْنَةُ زَيْنَبَ بِنْتِ النَّبِيِّ صلى الله عليه وسلم عَلَى عَاتِقِهِ، فَإِذَا رَكَعَ وَضَعَهَا وَإِذَا رَفَعَ مِنْ السُّجُودِ أَعَادَهَا
“I saw the Apostle (ﷺ) leading the people in prayer with Umima, daughter of Abu’l-‘As and Zainab, daughter of the Messenger of Allah (ﷺ), on his shoulder. When he bowed, he put her down, and when he got up after prostration, he lifted her again.” 
Al-Hafiz Ibn Hajar al-Asqalani when commenting on this hadith said: This hadith is evidence that children are permitted to enter the mosque. 
They also argued with a sahih hadith from Anas bin Malik R.Anhu, he said, the Prophet PBUH said:
إِنِّي لَأَدْخُلُ الصَّلَاةَ أُرِيدُ إِطَالَتَهَا فَأَسْمَعُ بُكَاءَ الصَّبِيِّ فَأُخَفِّفُ
“When I begin the prayer, I Intend to make it long, but I hear a boy crying; I then shorten it because of his mother’s feelings.” 
Al-Imam al-Syaukani when interpreting this hadith says: This hadith shows the permissibility of bringing children in a mosque. 
Coming back to the above question, according to madhhab Syafie, the final opinion stated that it is sunnah to separate the saf of children from the saf of adults. However, Imam al-Mawardi Rahimahullah stated in his book al-Hawi al-Kabir, citing the above issue, saying: “And some of our ashab have stated, the prioritized is to place the children (in the saf) between two men, for this would help the child to learn the movements and actions in prayer.” 
Likewise, in madhhab Syafie, an uncircumcised child is considered to bear najis under the penis of the boy. Thus, if an adult carries a child with najis while praying, then his prayer is invalid because one of the valid conditions of prayer is to be clean from any najis on one’s clothing, body and place.
Imam al-SYirazi Rahimahullah said: “Hence, if a person who is praying carries a pure living being in prayer, then his prayer is valid for the Prophet PBUH once carried Umamah bin Abi al-As in prayer. The reason is najis in a living creature has the same ruling with najis inside the person praying.”
Imam al-Nawawi Rahimahullah commented: “If a person carries a living pure creature where there is no apparent najis in prayer, then his prayer is valid without khilaf.” 
Syeikh Hasan al-Kaf said the prayer of a person who holds a rope that connects to najis is invalid, even if the rope doesn’t move when he moves. The reason is he is holding something that connects to najis, then it has the same ruling of him bearing the najis. However, it doesn’t affect the prayer if the najis is under his feet, for he isn’t considered as bearing the najis. 
Consequently, najis or something that has najis is the one bearing the person. For example, a person steps on his slippers without wearing them, or the najis is under his praying mat.
From this fact, solely touching or coming into contact with an uncircumcised child doesn’t invalidate the prayer. Likewise, if a person is certain that the child doesn’t bear najis, or if he isn’t circumcised, he has performed istinja’ properly, then it returns to the original and apparent ruling that a person isn’t with najis and it doesn’t invalidate a person’s prayer if he touches or carries it. This is based on the hadith of Umamah and the statement of Imam Nawawi stated above.
The approach of considering the apparent cab be seen in various rulings, among them is the permissibility but makruh ruling of using the utensils of non-Muslims even if the usual for them are not taking care of taharah (cleanliness) or it is a norm for them to interact with najis such as the Majus will usually wash their utensils with cow’s urine. The reason is the original ruling is that the utensils are pure and this precedes the usual ruling which is just an assumption. 
Thus, in our opinion, in this issue, the ruling is it is not invalid but it is best to separate the saf for adults and children as suggested by previous scholars.
 See Masjid Parlimen Umat, pg. 30
 Narrated by al-Baihaqi, (750). He said this hadith is marfu’ but not sahih (See al-Sunan al-Kubra, 10/177)
 Narrated by Muslim (845)
 See Fath al-Bari, 2/276
 Narrated by al-Bukhari (666) and Muslim (723)
 See Nailul Authar, 5/48
 See al-Hawi al-Kabir, 2/340
 See al-Majmu’ Syarh al-Muhazzab, 3/150
 See al-Taqrirat al-Sadidah (Qism Ibadat), pg. 20
 See al-Iqna’, pg. 49