يَا أَيُّهَا الَّذِينَ آمَنُوا أَطِيعُوا اللَّهَ وَأَطِيعُوا الرَّسُولَ وَأُولِي الْأَمْرِ مِنْكُمْ ۖ فَإِنْ تَنَازَعْتُمْ فِي شَيْءٍ فَرُدُّوهُ إِلَى اللَّهِ وَالرَّسُولِ إِنْ كُنْتُمْ تُؤْمِنُونَ بِاللَّهِ وَالْيَوْمِ الْآخِرِ ۚ ذَٰلِكَ خَيْرٌ وَأَحْسَنُ تَأْوِيلًا
O you who believe! Obey Allah and obey the Messenger and those in authority from among you; then if you quarrel about anything, refer it to Allah and the Messenger, if you believe in Allah and the last day; this is better and very good in the end. (4:59) - Shakir
Excerpt from Tafseer of Agha Mahdi Pooya1:
"Obey Allah and obey the messenger and the ulil amr (those vested with authority through His messenger)."
The command to obey is infinite-total obedience in all material, religious and spiritual matters, therefore, as this verse clearly signifies, the ulil amr must also be as just, wise and merciful as Allah and the Holy Prophet are, and he who - administers the affairs of mankind should be the khalifatullah (vicegerent of Allah) and the waliallah (representative of Allah whom He chooses after equipping him with His wisdom).
A careful study of the above references discloses that Ali, and after him, the remaining eleven Imams, in the progeny of the Holy Prophet, Ali and Fatimah, are the true successors of the Holy Prophet who have been referred to as ulil amr in this verse.