كتاب الإمارة
33  
The Book on Government
(5)
Chapter: The virtue of a just ruler and the punishment of a tyrant; Encouragement to treat those under one's authority with kindness and the prohibition against causing them hardship
(5)
باب فَضِيلَةِ الإِمَامِ الْعَادِلِ وَعُقُوبَةِ الْجَائِرِ وَالْحَثِّ عَلَى الرِّفْقِ بِالرَّعِيَّةِ وَالنَّهْيِ عَنْ إِدْخَالِ الْمَشَقَّةِ عَلَيْهِمْ
Sahih Muslim 142 e

It has been narrated on the authority of Hasan who said:

Ubaidullah b Ziyad visited Ma'qil b. Yasir al-Muzani in his last iliness. Ma'qil said (to him): I am narrating to you a tradition I heard from the Messenger of Allah (ﷺ). If I knew that I am to survive this illness. I would, not narrate it to you. I heard the Messenger of Allah (ﷺ) say: If God appointed anyone ruler over a people and he died while he was still treacherous to his people, God would forbid his entry into Paradise.
وَحَدَّثَنَا شَيْبَانُ بْنُ فَرُّوخَ، حَدَّثَنَا أَبُو الأَشْهَبِ، عَنِ الْحَسَنِ، قَالَ عَادَ عُبَيْدُ اللَّهِ بْنُ زِيَادٍ مَعْقِلَ بْنَ يَسَارٍ الْمُزَنِيَّ فِي مَرَضِهِ الَّذِي مَاتَ فِيهِ فَقَالَ مَعْقِلٌ إِنِّي مُحَدِّثُكَ حَدِيثًا سَمِعْتُهُ مِنْ رَسُولِ اللَّهِ صلى الله عليه وسلم لَوْ عَلِمْتُ أَنَّ لِي حَيَاةً مَا حَدَّثْتُكَ إِنِّي سَمِعْتُ رَسُولَ اللَّهِ صلى الله عليه وسلم يَقُولُ ‏ "‏ مَا مِنْ عَبْدٍ يَسْتَرْعِيهِ اللَّهُ رَعِيَّةً يَمُوتُ يَوْمَ يَمُوتُ وَهُوَ غَاشٌّ لِرَعِيَّتِهِ إِلاَّ حَرَّمَ اللَّهُ عَلَيْهِ الْجَنَّةَ ‏"‏ ‏.‏
Reference : Sahih Muslim 142e
In-book reference : Book 33, Hadith 28
USC-MSA web (English) reference : Book 20, Hadith 4500
  (deprecated numbering scheme)