When current is passed through the wire, it deflects the compass near it from its north-south position like a magnet. This is called magnetic effect of the current. As we know that needle of the compass is made up of thin magnet. When this needle comes in contact with another magnet then the like poles of the magnet repel each other and opposite poles attract each other. So the deflection is seen in the needle. In this case the wire behaves like a magnet and causes deflection in needle of the compass.