The Hajj is one of the five Pillars of Islam and takes place in the 12th month of the Islamic lunar calendar.
It is the journey that every adult Muslim must undertake at least once in their lives if they can afford it and are physically able.
On the first day of the Hajj, male pilgrims were required to change their clothes for two white cloths and enter the state of Ihram. Women put on modest clothing and covered their head, but not their face.
The pilgrims headed to Mecca's Grand Mosque, Islam's holiest site, and circled the Kaaba three times - a ritual known as tawaf. They could also walk seven times between the hills of Safa and Marwa, known as sai.
They then travelled to Mina, 5km (3 miles) away, where they will spend the night in a tent city before heading on Thursday to Mount Arafat, where the Prophet Muhammad is said to have delivered his final sermon.
The Saudi health ministry urged the pilgrims to follow strict guidelines to mitigate the effects of the heat, including avoiding exposure to the sun between 10:00 and 16:00, using umbrellas to shade themselves, and drinking water regularly.
Shaded areas have been enlarged by 50,000 sq m (12 acres) and more than 400 cooling units have been installed, according to the Hajj minister.
The cooling system in the Grand Mosque is the largest in the world, according to state TV.
More rubberized and cooled roads have also been built to reduce surface temperatures, and artificial intelligence will be used to monitor a fleet of drones and help manage crowds.
In 2015, more than 2,300 people were reportedly killed in a stampede in Mina.