كتاب الصلاة
4  
The Book of Prayers
(28)
Chapter: Straightening The Rows; The Virtue Of The Front Row And Then The Next; Competing With One Another For The Front Row; The People Of Virtue Should Take Precedence And Be Closest To The Imam
(28)
باب تَسْوِيَةِ الصُّفُوفِ وَإِقَامَتِهَا وَفَضْلِ الأَوَّلِ فَالأَوَّلِ مِنْهَا وَالاِزْدِحَامِ عَلَى الصَّفِّ الأَوَّلِ وَالْمُسَابَقَةِ إِلَيْهَا وَتَقْدِيمِ أُولِي الْفَضْلِ وَتَقْرِيبِهِمْ مِنَ الإِمَامِ
Sahih Muslim 439

Abu Huraira reported:

The Messenger of Allah (ﷺ) said: If you were to know, or if they were to know, what (excellence) lies in the first rows, there would have been drawing of lots (for filling them) ; and Ibn Harb said: For (occupying) the first row there would have been drawing of lots.
حَدَّثَنَا إِبْرَاهِيمُ بْنُ دِينَارٍ، وَمُحَمَّدُ بْنُ حَرْبٍ الْوَاسِطِيُّ، قَالاَ حَدَّثَنَا عَمْرُو بْنُ الْهَيْثَمِ أَبُو قَطَنٍ، حَدَّثَنَا شُعْبَةُ، عَنْ قَتَادَةَ، عَنْ خِلاَسٍ، عَنْ أَبِي رَافِعٍ، عَنْ أَبِي هُرَيْرَةَ، عَنِ النَّبِيِّ صلى الله عليه وسلم قَالَ ‏"‏ لَوْ تَعْلَمُونَ - أَوْ يَعْلَمُونَ - مَا فِي الصَّفِّ الْمُقَدَّمِ لَكَانَتْ قُرْعَةً ‏"‏ ‏.‏ وَقَالَ ابْنُ حَرْبٍ ‏"‏ الصَّفِّ الأَوَّلِ مَا كَانَتْ إِلاَّ قُرْعَةً ‏"‏ ‏.‏
Reference : Sahih Muslim 439
In-book reference : Book 4, Hadith 146
USC-MSA web (English) reference : Book 4, Hadith 880
  (deprecated numbering scheme)