It is narrated from Sayyiduna Abdullah bin Amr (may Allah be pleased with them both) that the Messenger of Allah (peace and blessings be upon him) said: "There are six gatherings such that if a believer is in any one of them, his protection is a responsibility upon Allah: in a mosque of congregational prayer, with a sick person, or at his funeral, or with a just ruler whom he honours and reveres."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 13668