Huzaifa narrates that the Messenger of Allah (ص) said:
"If the people knew since when Ali was named “Amir-ul-Mu’minin (the Commander of the Faithful), they would not have denied his grace and superiority. He further said, “He was called Amir-ul-Mu’minin while Adam was in his body at the time of breathing of spirit” [1]
Allah says, “And when your Lord brought forth from the children of Adam, from their backs, their descendants, and made them bear witness against their own souls: Am I not your Lord? They said: Yes! we bear witness.” [2]
So the Almighty Allah said, “I am your Lord and Muhammad your Prophet and Ali your leader.”
[1] Dailami, Firduas Al-Akhbar, V.3, page 339; Qunduzi, Yanabi al-Muwadda, V.2, page 248.
[2] A’raf / 172