a prophet or a righteous man?
The correct opinion is that
Al-Khadir (peace be upon him) is a prophet. This is based on his story with Musa (peace be upon him) narrated in Surah Al-Kahf (The Cave). Allah (Exalted be He) states that Al-Khadir scuttled the boat owned by poor fishermen, killed an apparently innocent boy, and built a wall for two orphan boys in a village whose people refused to feed them. After much criticism on the part of Musa, Al-Khadir explained the reasons for what he had done. (Part No. 3; Page No. 287) The story ended with Al-Khadir's declaration that all he had done was revealed to him by Allah, as Allah (Exalted be He) informs in the Qur'an:
And I did them not of my own accord. That is the interpretation of those (things) over which you could not hold patience.
May Allah grant us success. May peace and blessings be upon our Prophet Muhammad, his family, and Companions.