The compass had an iron needle in it which was magnetised. The pilot made the needle magnetic by stroking it with a piece of magnetic rock. This rock was called a lodestone, and pilots and navigators were sometimes known as lodesmen. The needle was balanced on a spike and it would turn to point to the magnetic north pole.
The direction the ship was sailing in was shown on a compass card.