Nearly three million Muslim pilgrims were performing the final rituals of the hajj on Tuesday as the world's largest annual gathering neared its close without major incident.
The most dangerous rite of the annual hajj proceeded peacefully as pilgrims rushed to throw 21 stones at pillars that symbolise the devil in the Saudi village of Mina, the last rite of the annual pilgrimage.
"Once I've finished the stoning, I will go to the Grand Mosque in Mecca to say farewell," said Abdallah Hamid Uglu, a 54-year-old Turk, in the mass of pilgrims rushing to complete the ritual before sunset.
In previous years, hundreds of people have been trampled to death in stampedes triggered by crowds trying to get close to the pillars to take their vengeance on the devil.
To complete the ritual, which is carried out over three days, pilgrims must stone the three pillars said to symbolise the devil.
The ritual is an emulation of Ibrahim's stoning of the devil at the three spots where he is said to have appeared trying to dissuade the biblical patriarch from obeying God's order to sacrifice his son, Ishmael.
Most pilgrims were to leave on Tuesday, after a farewell circumambulation of the Kaaba, a cube-shaped structure in the Grand Mosque into which is set the Black Stone, Islam's most sacred relic. Others stay for a further day.
Saudi authorities have installed a multi-level walkway through the stone-throwing site in a bid to avoid the trampling that caused the deaths of 364 people in 2006, 251 in 2004 and 1,426 in 1990.
More than 12,000 security guards organised the movement of pilgrims on the walkway this year with around 400 CCTV security cameras placed there to help manage the crowds.
No major incidents have been reported among the pilgrims, which the Saudi statistics office said numbered 2.93 million this year. The figure included 1.83 million foreigners.
Signup to our newsletter and follow us on Facebook and Twitter!
"Over 239,000 people have been working on ground" to serve the pilgrims and maintain order, Mecca governor Prince Khaled al-Faisal told reporters.
In the coming years, Mecca will become a "smart" city, said Prince Khaled with Saudi authorities having this year called in the latest electronic aids to help control the vast crowds.
The ministry of religious affairs has been sending 3.25 million text messages each day to the mobile phones of pilgrims to inform them of correct procedures for the hajj rites.
Saudi authorities also managed the crowds with electronic monitors which tracked each and every pilgrim during the five-day hajj, Hajj Minister Fuad al-Farsi said.
With motion sensors placed on surveillance cameras, "we are now able to report any excessive crowds" and to react in time, said the commander of the special emergency forces, Khaled al-Mohammadi.
The religious police also posted videos and documents for the guidance of pilgrims on video-sharing website YouTube. For the first time this year, the hajj was streamed live on YouTube in cooperation with the Saudi government.
Before leaving, most pilgrims buy up religious souvenirs and Zamzam holy water from a spring inside the Grand Mosque complex.
"I'm looking for gifts for my family back home in Jakarta," said Mohammed Islam, a 56-Indonesian, as he strolled among the market stalls scattered across the holy sites.
"A gift from Mecca has a symbolic value because it represents the holiest place on earth," he said.
The hajj is one of the five pillars of Islam and must be performed at least once in a lifetime by all those who are able to.