Although magnets were not invented, they were discovered by either the ancient Greeks or the Chinese. According to a legend, a Greek shepherd accidentally discovered lodestones in an area called Magnesia. Lodestone contains magnetite, which is a mineral found in nature as an iron ore.
However, the ancient Chinese also were familiar with lodestone and its magnetic properties. Nearly 4,500 years ago, they used lodestones in divining devices and mariner compasses. For these ancient people, lodestone magnetism was a natural phenomenon that was not understood.
It was not until the 1600s that magnetism began to be studied and understood by men like Peregrinus and William Gilbert. In 1820, Hans Oersted showed that there was a relationship between electricity and magnetism. Another important person that worked on magnetism and its relationship with electricity was James Clark Maxwell.