If a person is learning fiqh from one of the four madhhabs, then he sees a hadeeth that opposes his madhhab; and so he follows it and leaves his madhhab - then this is recommended, rather it is obligatory upon him when the proof has been made clear to him. This would not be considered as opposing his Imaam that he follows, since they - Abu Haneefah, Maalik, ash-Shaafiee and Ahmad, radiallaahu anhum ajmaeen - were all agreed upon this fundamental principle.
... As for the case whereby a person does not have any evidence which opposes the view of the scholars of the madhhab, then we hope that it is permissible to act upon it (the madhhab), since their opinions are better than our own opinions; they took their proofs from the sayings of the Companions and those who came after them. However, it is not essential to declare with certainty (al-jazm) that this is the Shareeah of Allaah and His Messenger, until the proof that is not contradicted in this issue is made clear. This is the action of the Salaf of this Ummah and its scholars - both previous and recent - as well as that which they criticised: namely having bigotted partisanship for particular madhhabs and leaving off following the proof... However, if there becomes clear to him something which necessitates preferring one saying over another; either due to detailed proofs if he knows and understands them, or because he holds one of the two people to be more knowledgeable about this matter and having more piety about what he says, and so he leaves the saying of that one for the saying of the other one - then this is permissible, rather it is obligatory. And there is a text from Imaam Ahmad concerning this.