In 1820 Oersted discovered that when an electric current passes through a conductor, a magnetic field is produced around the conductor, i.e., so long the current continues to flow through the conductor, it behaves like a magnet. This can be illustrated by a simple experiment described below.

Take a magnetic needle pivoted at its centre and free to move in horizontal plane. Take a thick and insulated copper wire PQ and connect it to the battery circuit through a key K and a variable resistance Rh.
Hold the wire PQ parallel and just above the axle of the magnetic needle and press the key. It is observed that Npole of the needle points towards the west so long the current continues to flow through the wire. It is also observed that if the current is increased or decreased, the deflection of the magnetic needle also increases or decreases.
If the direction of the current through PQ is reversed, i.e., if the current flows from Q to P, then N-pole of the needle is deflected towards east, this experiment shows that a magnetic field is set up around a current carrying conductor.