She married him without a guardian (wali) and now she wants to leave him, but he does not want that
What appears to be the case from your question is that the one you are asking about got married without the permission or knowledge of her guardian. If that is the case, then the more correct scholarly view is that the marriage is not valid, because the Prophet (blessings and peace of Allah be upon him) said: “Any woman who gets married without the permission of her guardian, her marriage is invalid, her marriage is invalid, her marriage is invalid.”
Narrated by Ahmad (24417), Abu Dawood (2083) and al-Tirmidhi (1102). Classed as saheeh by al-Albaani in Saheeh al-Jaami‘, no. 2709
Some of the imams are of the view that a marriage done without a guardian is valid, and they classed as da‘eef (weak) the hadeeth which stipulates that there should be a guardian in order for the marriage to be valid.
If the partners are separated in a marriage concerning the validity of which the scholars differed, it has to be done through talaaq (divorce).
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) said:
With regard to the marriage concerning which there is a difference of scholarly opinion, one of two scenarios apply:
1.The married person thinks that it is valid. If he thinks that it is valid, then the talaaq counts as such, and there is no confusion concerning that. For example: a man got married to a woman who breastfed from his mother three times, and he thinks that the breastfeeding that makes a person a mahram is five feedings. So the marriage is valid in his opinion. In this case talaaq undoubtedly counts as such.
Similarly, if he married a woman without witnesses, and he thinks that witnessing in marriage is not a condition of it being valid. In this case talaaq counts as such.
2.The married person does not think that the marriage is valid. In this case the scholars differed as to whether talaaq counts as such. Some of them said that talaaq does count as such in this case, and some of them said that it does not. Those who said that it does not count as such said that it is because talaaq is connected to the marriage contract. He does not think that the marriage is valid, so he cannot issue a talaaq. This reasoning is good and there is nothing wrong with it.
Those who say that it does not count as such say that is because, even though he does not think the marriage is valid, others may think that it is valid. So if he leaves her without talaaq, then a man comes to her who thinks that the marriage was valid, he can never marry her. So talaaq is valid with regard to a marriage concerning the validity of which there is a difference of opinion, even if the one who issues the talaaq does not think this is valid, because if he does not divorce her by talaaq, this will leave this woman in limbo.
If someone were to say: Why does the talaaq count as such when he does not think that the marriage is valid and talaaq is connected to it? We say: That is so that he will not prevent her from marrying someone else, because someone who thinks that that marriage was valid may want to marry her, and if this husband does not divorce her by talaaq, the other man will never be able to marry her, because he thinks that she is still married to him. Hence the author said: “Talaaq counts as such in the marriage concerning the validity of which there is a difference of opinion.” And it says in al-Rawd: “even if the one who is issuing the talaaq does not think that.”
End quote from Sharh al-Mumti‘ by Ibn ‘Uthaymeen, 13/25
For more information please see the answer to question no. 116575
Based on that, if they did the marriage contract in the manner mentioned in the question and they think that it was a valid marriage, then it is essential to divorce by talaaq, so that their separation will be confirmed.
If the husband refuses to divorce his wife by talaaq or to accept her khula‘, and she will be harmed by staying with him, then in this case she should refer the matter to the Muslim qaadi (judge) so that he can issue a divorce (talaaq) from him. If she is in a non-Muslim country, then she should refer the matter to the people of knowledge in the Islamic centres, because they take the place of the Muslim qaadi, and if they rule that she is divorced by talaaq, then it counts as such.
And Allah knows best.