Qibla Direction: How to Find the Direction of the Kaaba Accurately
What is the qibla?
The qibla is the direction a Muslim faces in prayer: the Kaaba in the Sacred Mosque at Makkah. Early Muslims first prayed toward the Farthest Mosque in Jerusalem, then were commanded to turn to the Kaaba in the second year of the Hijra: “We certainly see the turning of your face toward the heaven, and We will surely turn you to a qibla with which you will be pleased; so turn your face toward the Sacred Mosque” (Quran 2:144). From any point on Earth, the qibla is the direction of the shortest surface path from that point to the Kaaba, at latitude 21.4224779° N, longitude 39.8251832° E.
How is it computed? The great-circle equation
Because the Earth is a sphere, the shortest path between your city and the Kaaba is not the straight line you might draw on a flat map but a great-circle arc across the surface — the same routes airliners follow on long hauls. The qibla angle is computed by the standard spherical-trigonometry equation: with your latitude φ₁ and longitude λ₁, and the Kaaba’s φ₂ = 21.4224779° and λ₂ = 39.8251832°, the bearing B follows from:
Δλ = λ₂ − λ₁
B = atan2( sin Δλ · cos φ₂ , cos φ₁ · sin φ₂ − sin φ₁ · cos φ₂ · cos Δλ )
Qibla = ( B + 360° ) mod 360°
The result is the qibla angle: the bearing measured in degrees clockwise from true north. If your city’s qibla angle is, say, 118°, you face 118 degrees to the right of true north. This exact calculation is what the qibla direction tool on this site performs, along with the distance to the Kaaba in kilometers and miles along the same great circle.
True north vs magnetic north: a common trap
The computed qibla angle is measured from true north (Earth’s rotation axis), while your phone’s compass points to magnetic north. The gap between them — the magnetic declination — varies by location and drifts slowly over time, and it can be substantial: about 30 degrees in far-northern Canada, about 20 degrees in the opposite sense in the western United States, while negligible elsewhere. Each degree of error translates into a noticeable sideways miss over a distance as long as the path to the Kaaba.
Good phone compass apps compensate automatically using your location; with a simple magnetic compass you must add or subtract your city’s declination (by its east or west sign) from the qibla angle to get the correct compass bearing. Your location’s declination can be found from the global geomagnetic models of the Earth’s magnetic field.
Using your phone compass to find the qibla
- Open the qibla tool and choose your city, or allow automatic location (requires a secure HTTPS connection).
- Your city’s qibla angle in degrees and its on-screen direction will appear.
- Hold the phone flat and level, away from nearby metals and electronics (laptop edges, magnetic car mounts) so the compass is not deflected.
- Rotate until the pointer aligns with your city’s qibla angle; the direction in front of you is the qibla.
For a tool-free check: twice each year — around late May and mid-July at noontime in Makkah — the Sun passes directly over the Kaaba; at that moment, a vertical stick’s shadow at any place whose noon coincides points exactly opposite the qibla.
A finer question: the general direction or the exact point?
The schools of fiqh agree that what is required of one far from Makkah is facing the general direction of the Kaaba, not its exact geometric point: whoever strives to determine the qibla and errs, the prayer is valid by the majority’s position, for direction is by ability. Still, the more precisely you know your city’s qibla angle, the more complete and safe your prayer is — which is the purpose of precise tools such as this site’s. Muslim astronomers of the classical age attended to this computation with great care; al-Biruni’s “al-Athar al-Baqiya” and the Andalusian and Maghribi treatises on the qibla’s azimuth stand among the earliest records of computing it on the globe with the deviations of cities from Makkah’s meridian.
Sources and references
- NOAA National Centers for Environmental Information — World Magnetic Model: the official reference for magnetic declination values worldwide and their annual drift.
- Peer-reviewed study: Determining the Qibla Direction by Astronomical and Geometrical Methods: a contemporary treatment of the great-circle equation and qibla azimuth computation.
Related articles
- What Is the Hijri Calendar? Its Origin, Structure, and Difference from the Gregorian Calendar
- The Months of the Hijri Year: Names, Meanings, and the Sacred Months
- Umm al-Qura Calendar: Rules and Sighting Differences
- How Prayer Times Are Calculated: The Sun, Twilight Angles, and the Global Methods
- Islamic Occasions in the Hijri Year: Their Dates and Virtues
Frequently asked questions
Is the qibla angle the same everywhere?
No; the qibla angle changes from city to city — even slightly from district to district — because it is the great-circle bearing from your exact location to the Kaaba; the angle for Riyadh differs from Cairo’s or London’s.
Why doesn’t a straight line on a map show the qibla?
Flat maps distort paths on the globe; the shortest path between your city and the Kaaba appears as a curved line on a map, and the correct computation uses great circles, not straight lines.
How can I find the qibla without a compass?
Known methods include the twice-yearly sun alignment over the Kaaba (around late May and mid-July), when a vertical stick’s shadow points opposite the qibla, or knowing your city’s qibla angle and fixing it by the sun, stars or permanent landmarks. The easiest today is the qibla tool on this site.
What is the difference between the qibla angle and magnetic declination?
The qibla angle is measured from true north while the compass points to magnetic north; the difference between the two norths is your location’s magnetic declination, which must be accounted for when using a simple magnetic compass.