He did the marriage contract with her in the court without her family’s knowledge in order to force her wali (guardian) to accept the marriage. What must he do now?
Question

Eighteen years ago, I knew nothing about my religion, and I had no one to teach me the right path. But today, praise be to Allah, I have learned about my religion and my worldly affairs. There is a big problem in my life, which has to do with my marriage. I fell in love with a girl and loved her deeply, and I proposed to her more than once, but each time I met with refusal from her family, until I decided to do the marriage contract with her without the knowledge or prior approval of her family. This marriage was done in the personal affairs court in accordance with the Hanafi madhhab in the presence of a civil judge, who was not a man of religion (a shaykh or imam), and the witnesses to the marriage contract were unknown. After doing the marriage contract, I did not consummate the marriage with the girl, because the marriage contract was only a piece of paper to put pressure on her family so that they would agree to us getting married. In fact, after they came to know of this marriage contract, her wali (guardian) agreed, reluctantly, to the marriage. After that, I consummated the marriage with her. My question is: is my marriage to this girl regarded as valid according to Islamic teachings, or is it invalid, because it happened under compulsion?
Praise be to Allah.It is not permissible for anyone to do a marriage contract with a woman except with the permission of her guardian. There is a great deal of evidence to this effect, such as the words of the Prophet (blessings and peace of Allah be upon him): “There can be no marriage contract except with a guardian.” Narrated by at-Tirmidhi (1101), Abu Dawood (2085) and Ibn Maajah (1881) from Abu Moosa al-Ash‘ari (may Allah be pleased with him). Classed as saheeh by al-Albaani in Saheeh at-Tirmidhi.
The majority of scholars are of the view – and it is the correct view – that a marriage contract done without a guardian is invalid, 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 at-Tirmidhi (1102), Abu Dawood (2038) and Ibn Maajah (1879) from the hadith of ‘Aa’ishah (may Allah be pleased with her). Classed as saheeh by al-Albaani in Irwa’ al-Ghaleel (1840).
The Hanafis are of the view that it is valid for a woman to get married without a guardian.
Ibn Qudaamah (may Allah have mercy on him) said: It is not valid to do a marriage contract except with a guardian. A woman does not have the authority to give herself or any other woman in marriage, or to appoint anyone except her guardian to act on her behalf regarding her marriage, so if she does that, the marriage is not valid.
This was narrated from ‘Umar, ‘Ali, Ibn Mas‘ood, Ibn ‘Abbaas, Abu Hurayrah and ‘Aa’ishah (may Allah be pleased with them).
It is also the view of Sa‘eed ibn al-Musayyib, al-Hasan, ‘Umar ibn ‘Abd al-‘Azeez, Jaabir ibn Zayd, ath-Thawri, Ibn Abi Layla, Ibn Shubrumah, Ibn al-Mubaarak, ‘Ubaydullah al-‘Anbari, ash-Shaafa‘i, Ishaaq and Abu ‘Ubayd… Abu Haneefah said: She has the right to give herself and others in marriage, and to appoint someone to act on her behalf regarding her marriage.
Then Ibn Qudaamah stated that the view of the majority is more likely to be correct, and he quoted as evidence the hadiths quoted above." (Al-Mughni  9/345).
Given that there is a difference of opinion among the leading scholars regarding this matter, and that it is an issue that is subject to ijtihad, if a Muslim lives in a country which follows the Hanafi madhhab and regards a marriage contract done without a guardian as valid, and the marriage contract was done on that basis, then it may be deemed to be valid in that case, and the ruling of the court is not to be annulled.
Ibn Qudaamah (may Allah have mercy on him) said:
If a judge rules that this marriage contract is valid, or the one who did the marriage contract is a judge, it is not permissible to annul it. The same applies to all marriages that are done in an inappropriate way.
Al-Qaadi was of the view that it could be annulled.
This is also the view of al-Istakhri among the companions of ash-Shaafa‘i, because the marriage was done in a manner that is contrary to a religious text.
But the first view is more likely to be correct [that is, that it is not to be annulled], because it is a matter concerning which there is a difference of scholarly opinion and it is subject to ijtihad. So it is not permissible to annul the ruling. Moreover, this text is open to interpretation, and there are some reservations about its soundness, and there may be other evidence that contradicts it." (Al-Mughni 9/347).
Based on that, what we think is that the marriage should be deemed to be valid, even though what you did was a mistake. Therefore you must repent from that, and strive to seek the approval of your wife’s father, if he is still not happy with this marriage, because you mistreated him badly.
If you renew the marriage contract with her, with her father acting as her guardian in the marriage contract, in the presence of two witnesses of good character, that would be better and more prudent.
And Allah knows best.