The Prophet (peace and blessings be upon him) said, “Islam is built upon five pillars: testifying that there is no true god except Allah and that Muhammad is the Messenger of Allah, performing Prayer, paying theZakah, making the pilgrimage to the Sacred House (Hajj), and fasting the month of Ramadan.” (Al-Bukhari)

In his book Fiqh-us-Sunnah, the late Egyptian scholar Sheikh SayyedSabiq, may Allah bless his soul, states that:

There is a consensus among jurists concerning the prerequisites that must be found in a person for Hajj to be incumbent on him or her. These prerequisites are as follows:
he/she must be a Muslim.
he/she must be an adult.
he/she must be of a sound state of mind.
he/she must be free.
he/she must have the necessary power and ability to undertake the journey.
anyone lacking any of the above conditions is not obligated to perform Hajj. All these conditions (i.e. being a Muslim, being of adult age and of sound mind, being free, and possessing the power to discharge the duty) are equally valid with respect to all other forms of worship in Islam. This is based on a Hadith of the Prophet (peace and blessings be upon him) which says, “Three persons are not to be held accountable for their actions: a sleeping person until he awakes, a child until he comes of age, and a mentally disturbed person until he regains his reason.”
Freedom is an essential prerequisite for Hajj, for this worship needs time as well as financial ability. The Qur’an says, (Andpilgrimage to the House is a duty unto Allah for mankind, for him who can find a way thither.) (Al `Imran 3:97)