The Messenger (blessings and peace of Allaah be upon him) enjoined that people of knowledge and virtue should come forward to pray and should be close to him. He said: “Let those who are most wise and dignified be closest to me, then those who come after them, then those who come after them.” Narrated by Muslim (432).
But this hadeeth does not mean that others are prohibited from coming forward; rather it is meant to encourage those who are most wise and dignified to come forward to pray so that they will be behind the imam, in the first rows. But if they are lazy and fail to attend the prayer, then whoever gets to the front row or behind the imam first is more entitled to it, even if he is a young boy.
Ibn Hajr al-Haytami said in al-Isnaaf (2/41):
Al-Majd ibn Taymiyah favoured the view that the boy should not be sent back from his place if he got there first. He said: and this is the correct view.
Shaykh Ibn Baaz said: The correct view is that if they -- meaning boys -- come in the front rows, it is not permissible to send them back, and if they get to the front row or the second row first, then those who come after them should not make them stand up and move, because they attained the right first that others did not attain. So it is not permissible to send them back because of the general meaning of the hadeeths which speak about that, because making them move back will put them off prayer and will put them off competing in that, and that is not appropriate.
But if people have come together for a trip or for some other reason, then the men should form rows first and the boys second, then the women after them if there are women present. But as for taking them out of the row so that adults who came after them can take their place, that is not permissible.
With regard to the words of the Prophet (blessings and peace of Allaah be upon him), “Let those who are most wise and dignified be closest to me”, what is meant is to encourage those who are wise and most dignified to hasten to come to prayer and to be in the forefront of the people. It does not mean that those who got there before them should be pushed back for their sake. End quote.
Majmoo’ Fataawa al-Shaykh Ibn Baaz (12/400).
Shaykh Ibn ‘Uthaymeen said in al-Sharh al-Mumti’ (3/4):
If the boys reach a place first, then they are more entitled to it than others, because of the general meaning of the evidence that the one who reaches something first that no one else has reached before him is more entitled to it. The mosques are the houses of Allaah in which the slaves of Allaah are equal, so if a boy reaches the first row first -- for example -- and sits down, then let him stay where he is, because if we say that boys should be removed from the best place and we put them all in one place, that will lead to them playing about because they are together on their own in one row. End quote.
The Shaykh also said:
It is permissible for boys to be in the row even if they interrupt the row, because they are human beings; they are not stones or pillars, so they do not break up the row and it is not permissible for anyone to make them leave their places, even if they are directly behind the imam in the first row, because it is not permissible to move them from their places; end quote.
Liqa’ al-Baab al-Maftooh (106/24).
Based on the above, the one who is most entitled to the first row, even if he is directly behind the imam, is the one who gets there first, even if he is a boy, and even if there is someone who is superior to him. In that case it is not permissible to make him move back.
And Allaah knows best.