The needle of a compass is a tiny magnet, which points in the north-south direction. When a magnet is brought close to it, the needle gets deflected. When an electric current passes through a wire, it behaves like a magnet. This magnetic effect of the electric current makes the compass needle deflect from the north-south direction.