The short answer
There is no single date. Chinese records describe magnetic needles used for direction from roughly the 1000s, and European writers mention a magnetized needle for sailing by the late 1100s and 1200s. These dates are approximate, and historians still discuss the details, so treat any exact year with some caution.
Lodestones and early magnetic observations
Lodestone is a naturally magnetic iron ore, magnetite, and people in several ancient cultures noticed that it pulls on iron. Chinese texts from around the Han dynasty describe a spoon-shaped piece of lodestone set on a flat surface, which seemed to settle with its handle pointing south. Most historians think it was used for divination or geomancy rather than for finding direction at sea or on land, so it is better seen as an early step than as a true compass.
Magnetized needles in China
By the Song dynasty (960 to 1279), Chinese writers describe magnetized iron needles used for direction. Some accounts describe needles floated on water, and others describe needles balanced on a pivot. The scholar Shen Kuo, writing around the late 1000s, is often cited for one of the earliest written descriptions of a magnetic needle used for direction. He also noted that the needle did not point exactly at the geographic north. That observation is an early description of magnetic declination, the angle between magnetic north and true north.
Spread to the Islamic world and Europe
Trade routes carried the compass westward. Arabic writers mention a magnetized needle used at sea by the 1200s. In Europe, an English writer named Alexander Neckam described a magnetized needle used by sailors around 1190. The exact route of transmission is still debated, and historians do not agree on how much each region contributed.
Pivoting needles and the compass card
A major change came with the pivoting needle: a magnetized needle mounted on a pin so it could turn freely. A letter written in 1269 by a scholar named Petrus Peregrinus describes a needle on a pivot with a dial marked in degrees. Sailors later paired the needle with a card showing the points of the compass, which made a heading easier to read. This arrangement, a needle over a card, is the basic design behind many later compasses.
How the compass changed navigation
Before the compass, sailors relied on the sun, the stars and the coastline, and the early navigation methods that came before it were often limited to clear weather. A magnetic needle gave a steady reference that worked at night and under overcast skies. Combined with estimates of speed and time, a steady heading supported the dead reckoning navigation technique that sailors used for long voyages. The compass did not work alone. It was one tool among charts, log lines and experience.
How the compass connects to land navigation
Land navigators still rely on the same basic idea: a magnetic needle gives you a reference direction, and a map shows the terrain. Reading a map and compass together lets you take a bearing from a landmark, follow it on the ground, or work out where you are. Many of the land navigation techniques taught today depend on that pairing. If you want to practice, a good next step is using a compass for beginners, which covers taking a first bearing and following it.
Is it still relevant?
Largely yes. Hikers, orienteers and military trainees still learn to use a compass, and many ships and aircraft keep a magnetic compass as a backup to electronic systems. A compass needs no battery or signal, which is why it remains useful when other tools fail.
Summary
The navigational compass developed over many centuries rather than from one invention. Magnetic needles appear in Chinese sources from around the 1000s, and European sailors used them by the late 1100s and 1200s. The pivoting needle and compass card made the tool practical at sea, and the same principles still underpin the map and compass skills taught today.