The compass is a field detector.
Ørsted placed a conducting wire near a magnetic compass. With the circuit open, the compass aligned mainly with Earth's magnetic field. When current was switched on, the needle rotated and tended toward a direction at right angles to the wire.
No mechanical connection linked the wire to the needle. The current had produced a magnetic field strong enough to exert torque on the compass magnet. Reversing current reversed the field direction and therefore reversed the compass deflection.
