Sahih Muslim, Book 4, Hadith 145 (Muslim 976)

Abu Sa'id al-Khudri reported:

The Messenger of Allah (ﷺ) saw people at the end of the mosque, and then the (above-mentioned hadith) was narrated.