Compass is a simple instrument that is used for navigation and orientation. It has a magnetic needle or a card that works as a pointer to magnetic North of the Earth because the magnetized needle aligns itself with the lines of the Earth's magnetic field. Magnetic needle has a pivot and is balanced so the magnetic field of the Earth can pull one end of the needle toward the Earth's North magnetic pole, and the other toward the South magnetic pole. Because different poles of magnets attract, North pole of the magnetic needle will point to the Magnetic North pole (which is technically magnetic south pole of the Earth) and vice versa.
Problem is that magnetic poles of a planet Earth are not at the same place as its geographic poles so a compass does not point to a so called true north. Angle between true north and magnetic north is called magnetic declination and most of the maps have marked a measured local magnetic declination to allow the map to be oriented with a compass parallel to true north. Some of them, called declination maps, show lines of equal declination - isogonic lines. Some maps have a diagram that shows the relationship between magnetic north in the area concerned and true north with a label near the angle stating the size of the declination and of that angle, in degrees, mils, or both.
Magnetic compass has compass rose or a windrose, which is used to display the orientation of the cardinal directions: North, East, South and West and their intermediate points. It can have between 4 and 32 points. When the compass is used with a map, compass is leveled horizontally and left for a magnetic needle to find the North. When it is found, compass rose is rotated and a marked North on it is aligned with a magnetic North of the needle. That way we know sides of the world. North of the map is aligned with a North of the compass and that way map is oriented too. For more precise orientation, a magnetic declination is applied. The edge of the compass is placed on the map so that it connects the current location with the desired destination. The orienting lines in the base of the compass dial are then rotated to align with actual or true north by aligning them with a marked line of longitude (or the vertical side of the map). The resulting true bearing or map bearing can then be found at the degree indicator or direction-of-travel (DOT) line and then followed as an azimuth (course) to the destination.
Many sources can cause deviations in the behavior of the magnetic needle. Some of them are local magnetic anomalies - variations of the magnetization in the Earth's crust, nearby mountains and iron ore deposits, larger objects made of iron or steel, geomagnetic storms and electric currents. These are compensated by carefully placing of compass and by placing of compensating magnets under the compass itself.