The compass was a Chinese invention. There seems to be a reference to a south pointing spoon in a manuscript of the Han dynasty written in 83 AD. Another of the same period states that the jade collectors of Cheng carry a "south pointer" with them so that they will not lose their way. [Gies & Gies 1995 p 94]
Magnetized needles used as direction pointers are attested to in the 8th century AD in China, and between 850 and 1050 they seem to have become common as navigational devices on ships. [Gies & Gies 1995 p 94] White dates such use a bit later, citing dates of 1089-93 and 1116 for magnetized needles being used for geomancy and 1119 and 1122 for use as a mariner's compass. [White 1962 p 132]
Knowledge of the compass as a directional device came to Western Europe, probably sometime in the 12th century. It is essentially certain that it was knowledge of the Chinese compass that was transmitted to Western Europe. The assumed path is by the overland Silk Road, and not by sea on the "standard" trading route from China to India to Arab and Egyptian ports. This assumption is made because the Arabs seem to have learned of the compass from the Europeans.
The first mention of the directional compass (as opposed to magnets themselves, occurs in Alexander Neckam's De naturis rerum (On the natures of things), probably written in Paris in 1190. [Gies & Gies 1995 p 157] It is noted that Neckham's book was widely read by the end of the century, and that by about 1218 Jacques de Vitry considered the compass as a necessity for maritime navigation. By 1225 it was in use in Iceland. [White 1962 p 132]
It is reasonable to assume that the actual date of the introduction of the compass to Europe predates Neckham's note of it by a number of years. That explains the seemingly "rapid" adoption of it as noted by contemporary writers.
The first Moslem mention of the compass occurs in a Persian story of 1232-3. The first Arabic mention occurs in 1242. White notes that the Arabic word for compass is al-konbas, a further indication of transmission from the west. [White 1962 p 132]