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.
If your marriage contract had fulfilled the conditions of a valid marriage, like proposal and acceptance, the presence of the guardian or his deputy, and the presence of two witnesses, then it is a valid marriage and the ruling of the non-Islamic court is of no effect if it is contrary to that.
According to the most preponderant opinion of the scholars, that it is not permissible for a Muslim Judge to issue Khul' without the consent of the husband, but some other scholars are of the view that this is permissible.
However, if the Imaam of the mosque is authorized to act as the Muslim judge in your community and he had issued Khul’, then he is permitted to invalidate the ruling that he had issued if it has become clear to him that he was wrong.
The Fiqh Encyclopedia reads: “In principle, if the judge issues a ruling, then he is not permitted to invalidate it nor are others permitted to do so, unless it contradicts a religious text or a consensus of the scholars. However, some jurists stated – as we have already discussed – that if it appears to him that he was mistaken in his ruling, or that he forgot, or that he ruled contrarily to his view forgetfully, but in accordance with what some jurists ruled, and there is no evidence in this regard, then he may invalidate it himself exclusively, and this is the view of the majority of the scholars, …..the rule is that every ruling whose mistake is not known except by the one who issued it, like if he contradicted his previous opinion, then others cannot invalidate it, unless there is evidence in this regard, in which case, he would either invalidate it himself or others would invalidate it.”
Besides, if that Imaam is not qualified to give rulings in principle, then his rulings are not effective and they can be invalidated according to the view of many jurists .
Therefore, your wife is still your wife – as you mentioned in the question – and if the situation is as you mentioned about her, and you lost hope in rectifying her and her misconduct, then we advise you to separate from her and Allaah may compensate you with another wife better than her.
Indeed, you should learn a lesson from this experience, and you should be keen in the future to marry a woman who is religious and has a good moral conduct.
Allaah Knows best.