All perfect praise be to Allah, the Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallaahu ʻalayhi wa sallam, is His slave and Messenger.
When a Muslim who aspires to earn the reward that Allah prepared for the repentant and fears His threat for the sinners who transgress His limits is lured by the devil and his evil-enjoining self into committing a sin like the one which the questioner committed, it is becoming of him to be mainly concerned with what would save him from the sin which he openly committed as well as the violation of the sanctities of Allah. His main concern should be sincere repentance that fulfils all the conditions of repentance rather than seeking a way to return to a worldly matter. Moreover, a Muslim should ask ahead about the rulings of his religion and not do the deed first before asking about it. Allah, the Exalted, says (what means): {So, ask the people of the message if you do not know.} [Quran 16:43]
Al-Qurtubi said, “A lay-Muslim, who does not have adequate knowledge to practice Ijtihaad (personal reasoning) given his lack of qualification to do so, is obliged to consult the most knowledgeable scholars of his time and country and follow their fatwa; Allah, the Exalted, says (what means): {So, ask the people of the message if you do not know.} [Quran 16:43] He has to strive in looking for the most knowledgeable scholar until he finds the scholar upon whose knowledge most people agree.” [Tafseer Al-Qurtubi]
Thus, you come to realize that what the two of you did involves enormous negligence and unacceptable laxity. So, first of all, you must repent to Allah of the illegitimate affair which you had and the fornication which you committed. This woman is also obliged to repent to Allah for her illegitimate affair with the first man. There are certain conditions required for repentance to be sincere and acceptable. Please refer to fatwa 86527 to learn about those conditions.
The two reasons which you mentioned are both subject to a difference of opinion among the scholars. Some scholars held that a marriage contract conducted without the bride's Wali is valid. The same is true with regards to the marriage of an adulterous woman before repentance. Please, refer fatwas 86348 and 83176.
On the other hand, a marriage whose invalidity is subject to different scholarly opinions has the same legal effects and implications of a valid marriage. If a husband divorces his wife in such a marriage, divorce takes effect, as we have previously underlined in fatwas 86301 and 92478. Accordingly, renewing the marriage contract was invalid because the wife had been divorced with an irrevocable divorce with major separation (known in Arabic as: Talaaq baa'in baynoonah kubra).
We advise you to refer the case to the Shariah court, if there is any, or to an Islamic center or to consult a scholar orally. Do not mention that it was you who committed this sin; rather, use the third person pronoun, saying, for instance: “What is the ruling on a man or a woman who did such-and-such?”
Allah knows best.