A gravitational force between two masses is a fundamental force since it could not be accounted for in terms of anything more basic. So also an electric force between two charges is a fundamental force. However, the magnetic force between two magnets is not a new kind of force since its origin could be traced to the electrical interaction between the moving charges. It turns out that the causes of all magnetic fields are always moving charges.
Since a moving charge constitutes an electric current, we can say that an electric current gives rise to a magnetic field.
The fact that an electric current produces a magnetic field was discovered in the year 1820 by Oersted of Copenhagen. To repeat his experiment stretch a wire AB over a pivoted magnetic needle NS placed below it, the length of the wire being parallel to the axis of the needle. On sending a current through the wire, the needle is found to get deflected. It tends to set itself at right angles to the length of the wire. It, however, takes up a position inclined to the wire at an angle slightly less than 90°. The deflection of the needle is caused by the action of two fields- one due to the magnetic field of the wire and the other due to the earth’s field.
The magnetic field produced by an electric current can be obtained by using the law of Biot and Savart or Ampere’s circuital theorem.