1. The ruling of a disbeliever performing Hajj
Hajj is not valid from a disbeliever, nor is it obligatory upon him. It does not count for him if he happens to perform it. Scholars are in consensus that Hajj as a fard act only applies to Muslims. This was related by Ibn Hazm, Ibn Qudamah, and al-Shirbini.
2. The ruling of repeating Hajj if a Muslim apostasizes after its performance and then embraces Islam
One who apostasizes after performing Hajj and then embraces Islam is not obliged to re-perform Hajj after repenting from apostasy. This is the position of the Shafi`i and Hanbali schools and Ibn Hazm. It is the position of choice of Ibn `Uthaymin, and the fatwa of The Permanent Council.
Secondly: Sound Mind
Being of sound mind is a condition for the validity and sufficiency of Hajj. Thus, Hajj is not wajib for an insane person, nor does it fulfil the Islamic duty of Hajj if he happens to perform it. There is consensus amongst scholars that that Hajj is not wajib for the insane. This was related by Ibn Qudamah, al-Nawawi, and al-Mirdawi. There is also consensus amongst them that if such a person were to perform Hajj, that it does not fulfil the fard Hajj. This was related by Ibn al-Mundhir. The Ruling of an Insane Person’s Hajj if Their Guardian Enters into Ihram on Their Behalf
Scholars hold two positions regarding the validity of an insane person’s Hajj:
The first position: The Hajj of an insane person is valid if their guardian enters them into ihram on their behalf. This is the position of the majority: the Hanafis, Malikis (according to the well-known position), and Shafi`is.
The second position: The Hajj of an insane person is not valid even if their guardian enters into ihram on their behalf. This is the position of the Hanbali school, one position amongst Hanafis, Malikis, and Shafi`is, and the position of choice of Ibn `Uthaymin.