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

Abu Mas'ud al-Ansari reported:

The Messenger of Allah (ﷺ) said to us: The one who is well grounded in Allah's Book and is distinguished among them in recitation should act as; Imam for the people. and if they are equally versed in reciting it, then the one who has most knowledge regarding Sunnah; if they are equal regarding the Sunnah, then the earliest one to emigrate; If they emigrated at the same time, then the oldest one in age. No man must lead another in prayer in latter's house or where (the latter) has authority, or sit in his place of honour in his house, except that he gives you permission or with his permission.
وَحَدَّثَنَا مُحَمَّدُ بْنُ الْمُثَنَّى، وَابْنُ، بَشَّارٍ قَالَ ابْنُ الْمُثَنَّى حَدَّثَنَا مُحَمَّدُ بْنُ جَعْفَرٍ، عَنْ شُعْبَةَ، عَنْ إِسْمَاعِيلَ بْنِ رَجَاءٍ، قَالَ سَمِعْتُ أَوْسَ بْنَ ضَمْعَجٍ، يَقُولُ سَمِعْتُ أَبَا مَسْعُودٍ، يَقُولُ قَالَ لَنَا رَسُولُ اللَّهِ صلى الله عليه وسلم ‏ "‏ يَؤُمُّ الْقَوْمَ أَقْرَؤُهُمْ لِكِتَابِ اللَّهِ وَأَقْدَمُهُمْ قِرَاءَةً فَإِنْ كَانَتْ قِرَاءَتُهُمْ سَوَاءً فَلْيَؤُمَّهُمْ أَقْدَمُهُمْ هِجْرَةً فَإِنْ كَانُوا فِي الْهِجْرَةِ سَوَاءً فَلْيَؤُمَّهُمْ أَكْبَرُهُمْ سِنًّا وَلاَ تَؤُمَّنَّ الرَّجُلَ فِي أَهْلِهِ وَلاَ فِي سُلْطَانِهِ وَلاَ تَجْلِسْ عَلَى تَكْرِمَتِهِ فِي بَيْتِهِ إِلاَّ أَنْ يَأْذَنَ لَكَ أَوْ بِإِذْنِهِ ‏"‏ ‏.‏
Reference : Sahih Muslim 673c
In-book reference : Book 5, Hadith 367
USC-MSA web (English) reference : Book 4, Hadith 1422
  (deprecated numbering scheme)