كتاب الْمَسَاجِدِ وَمَوَاضِعِ الصَّلاَةِ
5  
The Book of Mosques and Places of Prayer
(53)
Chapter: Who is more entitled to lead the prayer
(53)
باب مَنْ أَحَقُّ بِالإِمَامَةِ
Sahih Muslim 672 a

Abu Sa'id al-Khudri reported Allah's Messenger (ﷺ) as saying:

When there are three persons, one of them should lead them. The one among them most worthy to act as Imam is one who is best versed in the Qur'an.
حَدَّثَنَا قُتَيْبَةُ بْنُ سَعِيدٍ، حَدَّثَنَا أَبُو عَوَانَةَ، عَنْ قَتَادَةَ، عَنْ أَبِي نَضْرَةَ، عَنْ أَبِي سَعِيدٍ الْخُدْرِيِّ، قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏ "‏ إِذَا كَانُوا ثَلاَثَةً فَلْيَؤُمَّهُمْ أَحَدُهُمْ وَأَحَقُّهُمْ بِالإِمَامَةِ أَقْرَؤُهُمْ ‏"‏ ‏.‏
Reference : Sahih Muslim 672a
In-book reference : Book 5, Hadith 362
USC-MSA web (English) reference : Book 4, Hadith 1417
  (deprecated numbering scheme)