Language:
كتاب فضائل أصحاب النبى صلى الله عليه وسلم
62  
Companions of the Prophet
(3)
Chapter: "Close the gates (in the Mosque), except the gate of Abu Bakr."
(3)
باب قَوْلِ النَّبِيِّ صلى الله عليه وسلم: «سُدُّوا الأَبْوَابَ إِلاَّ بَابُ أَبِي بَكْرٍ»
Sahih al-Bukhari 3654

Narrated Abu Sa`id Al-Khudri:

Allah's Messenger (ﷺ) addressed the people saying, "Allah has given option to a slave to choose this world or what is with Him. The slave has chosen what is with Allah." Abu Bakr wept, and we were astonished at his weeping caused by what the Prophet (ﷺ) mentioned as to a Slave ( of Allah) who had been offered a choice, (we learned later on) that Allah's Messenger (ﷺ) himself was the person who was given the choice, and that Abu Bakr knew best of all of us. Allah's Messenger (ﷺ) added, "The person who has favored me most of all both with his company and wealth, is Abu Bakr. If I were to take a Khalil other than my Lord, I would have taken Abu Bakr as such, but (what relates us) is the Islamic brotherhood and friendliness. All the gates of the Mosque should be closed except the gate of Abu Bakr."

حَدَّثَنِي عَبْدُ اللَّهِ بْنُ مُحَمَّدٍ، حَدَّثَنَا أَبُو عَامِرٍ، حَدَّثَنَا فُلَيْحٌ، قَالَ حَدَّثَنِي سَالِمٌ أَبُو النَّضْرِ، عَنْ بُسْرِ بْنِ سَعِيدٍ، عَنْ أَبِي سَعِيدٍ الْخُدْرِيِّ ـ رضى الله عنه ـ قَالَ خَطَبَ رَسُولُ اللَّهِ صلى الله عليه وسلم النَّاسَ وَقَالَ ‏"‏ إِنَّ اللَّهَ خَيَّرَ عَبْدًا بَيْنَ الدُّنْيَا وَبَيْنَ مَا عِنْدَهُ فَاخْتَارَ ذَلِكَ الْعَبْدُ مَا عِنْدَ اللَّهِ ‏"‏‏.‏ قَالَ فَبَكَى أَبُو بَكْرٍ، فَعَجِبْنَا لِبُكَائِهِ أَنْ يُخْبِرَ رَسُولُ اللَّهِ صلى الله عليه وسلم عَنْ عَبْدٍ خُيِّرَ‏.‏ فَكَانَ رَسُولُ اللَّهِ صلى الله عليه وسلم هُوَ الْمُخَيَّرُ وَكَانَ أَبُو بَكْرٍ أَعْلَمَنَا، فَقَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏"‏ إِنَّ مِنْ أَمَنِّ النَّاسِ عَلَىَّ فِي صُحْبَتِهِ وَمَالِهِ أَبَا بَكْرٍ، وَلَوْ كُنْتُ مُتَّخِذًا خَلِيلاً غَيْرَ رَبِّي لاَتَّخَذْتُ أَبَا بَكْرٍ، وَلَكِنْ أُخُوَّةُ الإِسْلاَمِ وَمَوَدَّتُهُ، لاَ يَبْقَيَنَّ فِي الْمَسْجِد ِباب إِلاَّ سُدَّ، إِلاَّ باب أَبِي بَكْرٍ ‏"‏‏.‏
Reference : Sahih al-Bukhari 3654
In-book reference : Book 62, Hadith 6
USC-MSA web (English) reference : Vol. 5, Book 57, Hadith 6
  (deprecated numbering scheme)