Amir D. Aczel notes that the Chinese knew about the magnetic properties of lodestone c. 800 BC.
Amir D. Aczel, The Riddle of the Compass: The Invention That Changed the World (New York: Harcourt, 2001), 78
The Chinese have known the lodestone and its mysterious properties since early antiquity. And while the lodestone’s ability to attract metal was well known in the Mediterranean, the Chinese also understood the lodestone’s direction-seeking property.
An early story known to have been written about 806 B.C. describes the palace of Ch’in Shi Huang Ti. The palace had what must have been the first metal-detection system in the world. The entire gate of the palace was made of lodestone, and anyone who tried to enter the palace bearing concealed iron weapons would be detected because of the great magnetic pull of the gate and immediately period.
The Iron Age in China began around 800 B.C. During this period, bone needles were replaced by iron ones, and the Chinese noticed that lodestone attracted the iron needles. Chinese authors have asserted that the understanding of magnetic phenomena led the Chinese to invent the magnetic compass as far back as the first century A.D., or even earlier.