
Somewhere near Mecca in the second year after the migration to Medina, Muhammad was leading prayer when a revelation came down, and in the middle of the ritual he turned. The congregation turned with him. Before that moment, Muslims had faced Jerusalem to pray, aligned with the Jewish practice they had known. After, they faced Mecca, a cube-shaped stone building that they believed had been built by Abraham and Ishmael long before any of them. The site of the switch became known as the Masjid al-Qiblatayn, the Mosque of the Two Qiblas. A billion and a half people now turn, five times a day, to face the same point.
The qibla is the direction of the Kaaba, and Muslims face it for far more than prayer. Animals are turned toward it for slaughter. The dead are aligned with it when buried. Pilgrims enter the state of ihram facing it. Making a supplication toward it is encouraged. Spitting or relieving oneself toward it is not. In mosques around the world, the qibla is marked by a mihrab, a niche built into the wall, which became a standard feature during the Umayyad period. Before the mihrab, the orientation of the building itself was the signal. You did not need the niche if the wall was the niche. Most scholars accept that facing the general direction suffices when the exact direction cannot be determined, but the precise question of what "facing the Kaaba" means at a distance has occupied Islamic mathematicians for over a thousand years.
The Kaaba is less than 20 meters wide. From Medina, 338 kilometers away, a deviation of a single degree shifts the imaginary line of sight by 5.9 kilometers, more than the entire city of Mecca across. From Jakarta, some 7,800 kilometers away, a one-degree error throws you 100 kilometers off. Even a deviation of a single arcsecond produces a shift of more than 100 meters at that range. Scholars understood this problem almost immediately. Some schools insisted on precise alignment when it was possible. Others, including Abu Hanifa and al-Qurtubi, considered that the general direction was enough, because demanding perfect accuracy from every farmer in al-Andalus would make the religion impossible to practice. In al-Andalus an entire southeastern quadrant was considered valid. In Central Asia, the southwestern. The mercy was geographical.
In the first two centuries of Islam, Muslims used whatever methods they had. When Muhammad was in Medina he faced due south, because Mecca is due south of Medina, and the habit of facing due south spread with the early conquests. In al-Andalus at one end of the Islamic world and in Central Asia at the other, mosques were built facing south when Mecca was nowhere near that direction. Other methods drew on pre-Islamic Arabian "folk astronomy": the rising or setting points of specific stars, the direction of certain winds, the sunrise at the equinox. Sunrise at the equinoxes, due east, was the qibla in the Maghreb. The rising point of Canopus was used in Syria. The direction of the North Star was used in Yemen. All of these were considered legitimate by jurists, even after better methods arrived, because they had been used by the Companions of the Prophet.
The mathematical qibla begins in Baghdad in the mid-9th century, when Muslim astronomers, working from translations of Greek and Indian texts, developed exact methods to determine the direction of the great circle passing through any point on Earth and the Kaaba. Habash al-Hasib, al-Nayrizi, Ibn Yunus, Abu al-Wafa, Ibn al-Haytham, and al-Biruni all produced solutions equivalent to what spherical trigonometry still uses today. In the 14th century, Shams al-Din al-Khalili, the timekeeper of the Umayyad Mosque of Damascus, compiled a qibla table with 2,880 entries, covering coordinates up to 60 degrees of longitude from Mecca at latitudes between 10 and 50 degrees north. The historian David A. King considers it the most impressive of all medieval qibla works. The problem was that these scholars had no accurate way to measure longitude. The math was right. The inputs were not.
The mismatch between folk qibla, astronomical qibla, and the true qibla produced cities where every mosque pointed a different direction. The Egyptian historian al-Maqrizi, writing in the 15th century, recorded the qiblas of Cairo's mosques: 90 degrees (due east), 117 (winter sunrise), 127 (astronomer's calculation), 141 (the Mosque of Ibn Tulun), 156 (rising point of Canopus), 180 (due south, mimicking Muhammad in Medina), and 204 (the setting point of Canopus). The modern calculation for Cairo is 135. None of al-Maqrizi's mosques had it exactly right, because the geographic data they used was wrong. Cordoba's major mosques recorded qiblas of 113, 120, 135, 150, and 180 degrees in the 12th century. Samarkand's recorded 180, 225, 230, 240, and 270. The streets of those cities still follow the walls of those mosques. A disagreement about the shape of the Earth became a disagreement about the shape of a neighborhood.
Accurate longitudes arrived with 18th- and 19th-century cartographic surveys. GPS made the modern qibla a button on a phone. When a person stands in San Francisco today, the great circle direction to the Kaaba is 18 degrees 51 minutes east of north, which looks wrong on a Mercator map (Mecca lies roughly southeast) but is correct on a globe. From Japan, the qibla is northwest. From Alaska, it is almost due north. In 2007, Malaysian astronaut Sheikh Muszaphar Shukor flew to the International Space Station during Ramadan, and the question of how to face Mecca from low Earth orbit at 27,000 kilometers per hour generated real religious rulings. The Malaysian National Fatwa Council advised determining the qibla "based on what is possible," which is exactly what every Muslim traveler, in every generation, from the deserts of al-Andalus to the orbit of Earth, has ultimately had to do.
The Kaaba, the reference point for the qibla, is located at 21.4225 degrees north, 39.8252 degrees east, inside the Masjid al-Haram in Mecca. The nearest major airport is King Abdulaziz International in Jeddah (OEJN), roughly 80 km west. Mecca airspace is restricted, with no-fly zones over the Grand Mosque. Hot desert climate, visibility often reduced by dust in summer. On 27-28 May and 15-16 July, the Sun passes directly over the Kaaba, and for a few minutes around 12:18 and 12:27 Saudi time, any vertical object anywhere with a line of sight to the Sun casts a shadow pointing directly away from Mecca.