Compass is an instrument that has magnetic needle that, when it is positioned horizontally, can rotate freely around its vertical axis and because the needle aligns with North-South direction it is used for navigation and orientation.
First compass was invented in China during the Han Dynasty between the 2nd century BC and 1st century AD but its principal history is much longer. Plinius the Elder, which lived from 23 to 70 year, wrote that that a shepherd called Magnes had noted that the nails of his shoes and the iron point of his staff clung to the rocks on Mount Ida. Rocks were rich in magnetite. After that people found that steel or hardened iron can be magnetized when rubbed against magnetite and it will acquire same properties as magnetite. Chinese found out that when a lodestone, a naturally magnetized ore of iron, is hung or placed so that it can rotate freely, will always point at the same direction. They used this for divination and geomancy: they searched for gems, selected sites for houses and used it in feng shui. One of the characteristic compasses of that time was a south-pointing ladle whose handle pointed south. Only in 11th century, compass is used for navigation, first on land and then on water. First compasses were made of lodestone but later a magnetized steel needle is used as a main part of a compass. Naval compasses of China were made in the form of a magnetic needle that floated in a bowl of water which allowed for the needle to stay in horizontal position, especially at the rough sea.
Somewhere between 12th and 13th century, compass arrived in Europe in both dry and floating forms. It prolonged sailing season, which was earlier between October and April and relied on the clear skies, to the whole year which in turn resulted in a gradual, but sustained increase in shipping movement.
Compass appeared in Islam world in 13th century. Except for naval navigation it was also used for astronomical purposes, same as in Europe. It was also used as Qibla (Kabba) indicator to find the direction to Mecca for daily prayers. Improved version of this indicator was invented by Syrian astronomer and timekeeper Ibn al-Shatir in 14th century. It was a combination of universal sundial and a magnetic compass.
In time, different variants of compass were invented. Dry mariner's compass was invented in Europe in 14th century and was standard compass placed in three-ring gimbals which held compass in horizontal position. A bearing compass is mounted in such a way that it allows the taking of bearings of objects. Liquid compass has its needle immersed in liquid that holds it always in horizontal position and dampens shock and vibration.
Modern compasses have basic principle the same as those from 20 centuries ago, but are made from more modern materials and have incorporated advanced improvements. Magnetized needle or a dial are placed inside a capsule completely filled with a liquid. Casing is often transparent which allows for use of compass on the map. Except for orientating and navigation, compasses are used in building orientation, mining and astronomy.