Oersted observed that a magnetic compass needle deflected violently when brought close to a current carrying wire. This effect led him to conclude that moving charges in the form of a current possesses certain magnetic field, so a wire can act as a magnet.