WHEN pilots take to the skies over northern Africa next week they will be issued with special instructions and charts. During the haj, air traffic across the continent changes. Rather than mostly flying north or south, flocks of aircraft wing their way east to Saudi Arabia, home to Islam’s holiest sites.

The annual pilgrimage, which the Koran enjoins every believer who can afford it to perform at least once in a lifetime, is much easier for pilgrims than it used to be. In the old days they trudged for days over land. Now they fly, and even a seat in economy class is comfier than a thousand-mile trek across the Sahara. Over 2m Muslims from 183 countries will descend on Mecca and its surroundings in time for September 22nd, when the haj starts this year. Managing that ingress requires heroic logistics.

In the past few years as the crowds have swollen, Saudi Arabia has moved to restrict the numbers. A dedicated ministry allots each country a quota of visas based on its Muslim population; this has been reduced since 2013 due to renovation works in Mecca. Each country then distributes them by lottery. Muslims can only apply, in their home country, if they haven’t been in the past five years—an exception is given to those accompanying a woman under 45 years old, all of whom must have a male mahram, or guardian.

A lucky few might win a fully-paid trip funded by their government. But most visa-endowed pilgrims must next pick a package from a Saudi-approved agency. These range from a luxury five-star experience to setting up camp somewhere or bedding down on a hotel roof. “This year we’re hosting guests mainly from Egypt, Morocco, Senegal and France,” says Muhammad Sabry of Elaf Ajyad, a mid-range hotel in Mecca.

To ferry the pilgrims, extra flights are put on, often, as in Egypt, departing from special “seasonal” terminals. Air India, for example, has said it will operate 230 direct flights from seven Indian cities to Jeddah, the main disembarkation point for the haj. (Pilgrims may not leave the western area of Saudi Arabia during their stay.) On arrival, pilgrims speed down a four-lane highway to Mecca, about 65km (40 miles) away. They enter a state of ihram, or holiness. Men must don a seamless two-part white outfit; women a simple dress that leaves their hands and face exposed.

Ensuring that the pious masses can safely move between the sites during the five days of the pilgrimage, is particularly tricky. They must walk (or be bussed if they are elderly or weak) distances of several kilometres between Mount Arafat, the Grand Mosque of Mecca and the valley of Mina. Accidents have become rarer since a stampede in 2006 left 363 people dead. But on September 11th a crane at the Grand Mosque collapsed, killing 107 people performing the umrah, the lesser pilgrimage.

In recent years the kingdom has modified several sites, which has altered the rituals themselves. Special electronic gates let pilgrims into the site. Muslims circumambulate the Kaaba, the black cube in the Grand Mosque, both on the ground and on a platform above it. The faithful need not kiss the black stone on its eastern corner, as is traditionally required, but can point to it instead. They can also appoint someone else—usually a butcher—to slaughter an animal, as is required at the end of the haj. Last year 2.5m animals were sold; many had to be imported.

Saudi Arabia says it will deploy 100,000 members of its security forces to protect the areas and control crowds. This year is particularly tense: Islamic State has claimed three bombings at Shia mosques in the country’s eastern province this summer. Both Sunni and Shia Muslims take part in the haj; the Saudi government is anxious that none be murdered.

With so many people from so many places crammed together in the heat, exhaustion, dehydration and infections are common. Saudi Arabia is struggling to put an end to Middle East Respiratory Syndrome, a deadly virus. The government has set up 25 hospitals nearby; the Red Crescent will run 69 medical centres.

The logistics will only get harder. The Saudi government is spending billions of dollars on expanding the holy sites’ capacity (luckily the haj makes the country some $8.5 billion each year, by one estimate). The Grand Mosque will soon be able to accommodate 1.6m pilgrims at once: extra floors, 21,000 toilets and hundreds of escalators and lifts are being built. (Female pilgrims have often complained that there are not enough toilets.)

The swelling crowds are changing the holy places beyond recognition. Garish hotels have replaced ancient neighbourhoods and non-Islamic sites in Mecca. An ugly clock tower looms above the Grand Mosque. Shops selling everything from Baskin-Robbins ice cream to Rolex watches abound. “Mecca and Medina are meant to be sanctuaries, not cities,” says Sami Angawi, an architect who runs the Haj Research Centre, a think-tank. Yet where there are pilgrims, there are profits.