The Judge's Ruling does not allow the Prohibited or prohibit the Lawful
It is reported in the Two Sahihs that Umm Salamah narrated that Allah's Messenger said:
«أَلَا إِنَّمَا أَنَا بَشَرٌ، وَإِنَّمَا يَأْتِينِي الْخَصْمُ، فَلَعَلَّ بَعْضَكُمْ أَنْ يَكُونَ أَلْحَنَ بِحُجَّتِهِ مِنْ بَعْضٍ فَأَقْضِيَ لَهُ، فَمَنْ قَضَيْتُ لَهُ بِحَقِّ مُسْلِمٍ فَإِنَّمَا هِيَ قِطْعَةٌ مِنْ نَارٍ، فَلْيَحْمِلْهَا أَوْ لِيَذَرْهَا»
(I am only human! You people present your cases to me, and as some of you may be more eloquent and persuasive in presenting his argument, I might issue a judgment in his benefit. So, if I give a Muslim's right to another, I am really giving him a piece of fire; so he should not take it.)
The Ayah and the Hadith prove that the judgment of the authorities in any case does not change the reality of the truth. Hence, the ruling does not allow what is in fact prohibited or prohibit what is in fact allowed. It is only applicable in that case. So if the ruling agrees with the truth, then there is no harm in this case. Otherwise, the judge will acquire his reward, while the cheater will acquire the evil burden.
This is why Allah said:
[وَلاَ تَأْكُلُواْ أَمْوَلَكُمْ بَيْنَكُم بِالْبَاطِلِ وَتُدْلُواْ بِهَآ إِلَى الْحُكَّامِ لِتَأْكُلُواْ فَرِيقًا مِّنْ أَمْوَالِ النَّاسِ بِالإِثْمِ وَأَنتُمْ تَعْلَمُونَ ]
(And eat up not one another's property unjustly, nor give bribery to the rulers (judges before presenting your cases) that you may knowingly eat up a part of the property of others sinfully.) meaning, `While you know the falsehood of what you claim. ' Qatadah said, "O son of Adam! Know that the judge's ruling does not allow you what is prohibited or prohibit you from what is allowed. The judge only rules according to his best judgment and according to the testimony of the witnesses. The judge is only human and is bound to make mistakes. Know that if the judge erroneously rules in some one's favor, then that person will still encounter the dispute when the disputing parties meet Allah on the Day of Resurrection. Then, the unjust person will be judged swiftly and precisely with that which will surpass whatever he acquired by the erroneous judgment he received in the life of this world.''
[يَسْـَلُونَكَ عَنِ الأَهِلَّةِ قُلْ هِىَ مَوَاقِيتُ لِلنَّاسِ وَالْحَجِّ وَلَيْسَ الْبِرُّ بِأَن تَأْتُواْ الْبُيُوتَ مِن ظُهُورِهَا وَلَـكِنَّ الْبِرَّ مَنِ اتَّقَى وَأْتُواْ الْبُيُوتَ مِنْ أَبْوَبِهَا وَاتَّقُواْ اللَّهَ لَعَلَّكُمْ تُفْلِحُونَ ]
(189. They ask you (O Muhammad) about the crescents. Say: "These are signs to mark fixed periods of time for mankind and for the pilgrimage.'' It is not Al-Birr (piety, righteousness, etc.) that you enter the houses from the back, but Al-Birr is from Taqwa. So enter houses through their proper doors, and have Taqwa of Allah that you may be successful.)