If we bring a bar magnet near a magnetic compass, its needle will get deflected. When we bring North pole of a bar magnet near the magnetic compass, its needle will be deflected away from the magnet as shown in the first figure.
However, when we bring South pole of bar magnet near the magnetic compass, the needle will be deflected towards the magnet as shown in the second figure.