Praise be to Allaah.
The Prophet (peace and blessings of Allaah be upon him) commanded us to make
the rows straight and to close the gaps in them, and to complete the first row, then subsequent rows. That is mentioned in well-known ahaadeeth,
such as that narrated by al-Bukhaari (690) and Muslim (433) from Anas, that the Prophet (peace and blessings of Allaah be upon him) said:
“Make your rows straight, for straightening the rows is part of the perfection of prayer.” According to the version narrated by al-Bukhaari: “… is
part of the establishing of prayer.”
Ahmad (12374), Abu Dawood (671) and al-Nasaa’i (818) narrated from Anas that the
Messenger of Allaah (peace and blessings of Allaah be upon him) said: “Complete the first row, then the next one, and if there is to be any
incomplete row let it be the last row.” Classed as saheeh by al-Albaani in Saheeh Abi Dawood.
Ahmad (5724) and Abu Dawood (666) narrated from ‘Abd-Allaah ibn ‘Umar that the
Messenger of Allaah (peace and blessings of Allaah be upon him) said: “Straighten the rows, for you form rows like the angels, and keep your
shoulders in line with one another, and fill the gaps, and do not leave any room for the Shaytaan. Whoever joins a row to complete it, Allaah will
take care of him and whoever interrupts a row, Allaah will cut him off.” This hadeeth was classed as saheeh by al-Albaani in Saheeh Abi Dawood.
Based on this, then your bringing worshippers closer to one another and filling
the gap in the row is an act that is prescribed in sharee’ah, so long as that does not lead to crowding the worshippers and annoying them.
And Allaah knows best.