Answer
There are two aspects to this query: a) A ruler being just and unjust, b) A ruler being Muslim and non-Muslim.
A ruler who is upright and just is more superior than a Muslim ruler who is unjust. The incident of Najashi in the initial days of Islam when the Muslims migrated to Abyssinia is a clear example. A Muslim ruler who is unjust is only superior to a non-Muslim just ruler with regard to his beliefs and not his service to his subjects.
and Allah Ta’ala Knows Best
Mufti Ebrahim Desai