The compass was developed over centuries. Early compasses were probably in use in ancient China, in Norway during the 1100's and in the Mediterranean shortly after. There's evidence that early Viking explorers used rudimentary compasses to navigate to "Vinland" on the northern tip of Newfoundland even earlier.
The first onboard compass was probably an iron pin magnetized by a lodestone, a magnetized ferrous rock. It was placed on a piece of cork in a bowl of water to maintain its northerly orientation. Columbus may have used such a device to keep his westward heading during his voyages to the Americas, although there is some dispute over this . Later explorers certainly had such devices, likely improved ones. In the 16th century, a better understanding of the concepts of magnetism and variation resulted in more sophisticated compass design as the age of exploration began in earnest.