Sahih Muslim 4731
The Book on Government
وَحَدَّثَنَا أَبُو غَسَّانَ الْمِسْمَعِيُّ، وَإِسْحَاقُ بْنُ إِبْرَاهِيمَ، وَمُحَمَّدُ بْنُ الْمُثَنَّى، قَالَ إِسْحَاقُ أَخْبَرَنَا وَقَالَ الآخَرَانِ، حَدَّثَنَا مُعَاذُ بْنُ هِشَامٍ، حَدَّثَنِي أَبِي، عَنْ قَتَادَةَ، عَنْ أَبِي الْمَلِيحِ، أَنَّإِنِّي مُحَدِّثُكَ بِحَدِيثٍ لَوْلاَ أَنِّي فِي الْمَوْتِ لَمْ أُحَدِّثْكَ بِهِ سَمِعْتُ رَسُولَ اللَّهِ صلى الله عليه وسلم يَقُولُ " مَا مِنْ أَمِيرٍ يَلِي أَمْرَ الْمُسْلِمِينَ ثُمَّ لاَ يَجْهَدُ لَهُمْ وَيَنْصَحُ إِلاَّ لَمْ يَدْخُلْ مَعَهُمُ الْجَنَّةَ " .
It has been narrated on the authority of Abu Malik that Ubaidullah b. Ziyad visited Ma'qil b. Yaser in the latter's illness. Ma'qil said to him:I am narrating to you a tradition. If I were not at death's door, I would not narrate it to you. I heard the Messenger of Allah (may peace he upon him) say: A ruler who, having obtained control over the affairs of the Muslims, does not strive for their betterment and does not serve them sincerely shall not enter Paradise with them
Text from the public-domain hadith-api dataset. Numbering follows that dataset and can differ by a few from some printed editions — check the wording, not only the number.