Magnetism is the force of attraction or repulsion between two substances. Ancient sailors used magnetite, the first known magnetic rock, as a compass by tying a piece to a string and suspending it to determine directions. Atoms have magnetic properties due to their spinning electrons and electric charge, but in most objects the magnetic domains of atoms are not uniformly aligned, resulting in weak magnetic forces. Strong magnetism can be induced by exposing objects to magnetic fields, which causes atomic domains to align uniformly. The first natural magnets were formed when iron-containing volcanic magma was magnetized by contact with the Earth's magnetic field.