All perfect praise be to Allaah, The Lord of the worlds. I testify that there is none worthy of worship except Allaah and that Muhammad is His slave and Messenger.
Ibn Taymiyyah cited these statements in many of his books. He wrote:
"It has been narrated on the authority of Umm Salamah that the Prophet said, 'You refer your disputes to me, and I am only a human being. Perhaps some of you may be more eloquent in presenting your case than others, so I rule in their favor because of what I hear from them. If I pass a judgment in favor of one of you that detracts from his brother's rights, then he should not take it, for I sliced off for him a portion from the Hell.' [Al-Bukhari and Muslim]
Muslims agreed that the ruler's judgment on matters untackled by the sharee'ah (considerations of public interest in matters which were not specifically addressed by Islamic texts) does not change the religious ruling in reality (baatinan, although it is effective ostensibly [thaahiran]). For example, if he wrongfully or mistakenly judged that ʻUmar's wealth belonged to Zayd by accepting a testimony or evidence in this regard, then that would not have changed the religious ruling in this regard. The same applies if he wrongfully gave his verdict about the validity of any given contract, annulment of a marriage, or a sale contract, his wrong judgment does not change the religious ruling...
Some scholars, however, held that the ruler's judgment changes the religious ruling in such cases because he has the authority to judge the validity of contracts and annulments. The correct view is that of the majority of the scholars; it is the scholarly view adopted by Maalik, Ash-Shaafiʻi, Ahmad ibn Hanbal, Fiqh scholars of Hijaaz, scholars of Hadeeth, and many of the Fiqh scholars of Iraq..." [Majmooʻ Al-Fataawa]
Abu Haneefah held a view contrary to that of the majority of scholars regarding the contracts and annulments. His students Muhammad ibn Al-Hasan and Al-Qaadhi Abu Yoosuf opposed him in this regard. Al-Kaasaani wrote:
"If a man claimed that he married a woman, and she denied it, but he brought forth two false witnesses claiming that the marriage took place and the judge gave his verdict that the woman is his wife while the man and witnesses know that no marriage contract was conducted, then it is lawful for the man to have intercourse with her and lawful for her to allow him to do so according to Abu Haneefah, but it is unlawful according to them (Muhammad ibn Al-Hasan, Al-Qaadhi Abu Yoosuf and Ash-Shaafiʻi). The same applies to the case when two witnesses testify that a man divorced his wife thrice while he denies it and the judge gives his verdict that the marriage bond has been annulled irrevocably and one of the two witnesses married her, it is lawful for him to have intercourse with her even if he knew that the testimony was false, but it is unlawful according to them (Muhammad ibn Al-Hasan, Al-Qaadhi Abu Yoosuf and Ash-Shaafiʻi) " [Al-Badaa'iʻ wa As-Sanaa'iʻ]
This means that Abu Haneefah held that the verdict of the judge pertaining to the validity of contracts such as marriage and annulments such as divorce is effective in reality (baatinan) and ostensibly (thaahiran) because he has the authority to judge such matters.
Allaah knows best.