A relationship between a man and a woman outside of marriage, which is what is called an unlawful relationship, is haraam, regardless of the level of this relationship and whether it goes as far as an intimate relationship or zina (sexual relationship), which is the most reprehensible and abhorrent type of sins and one of the gravest of major sins that poses the greatest danger to the individual’s religious commitment and faith, or it is less than that, such as looking, touching or kissing. All of that is haraam and these are types of zina in the general sense, and are things that lead to the greater immoral action.
If marriage takes place after a haraam relationship between a man and woman, then one of the following scenarios must apply:
Either that marriage comes after an illegitimate sexual relationship, in which case the marriage is not valid except on the condition that both the man and woman repent from zina and it be established that the woman is not pregnant as a result of the haraam relationship, because Allah, may He be exalted, says (interpretation of the meaning): “The adulterer/fornicator marries not but an adulteress/fornicatress or a Mushrikah; and the adulteress/fornicatress, none marries her except an adulterer/fornicater or a Mushrik [and that means that the man who agrees to marry (have a sexual relation with) a Mushrikah (female polytheist, pagan or idolatress) or a prostitute, then surely, he is either an adulterer/fornicator, or a Mushrik (polytheist, pagan or idolater). And the woman who agrees to marry (have a sexual relation with) a Mushrik (polytheist, pagan or idolater) or an adulterer/fornicator, then she is either a prostitute or a Mushrikah (female polytheist, pagan, or idolatress)]. Such a thing is forbidden to the believers (of Islâmic Monotheism)” [al-Noor 24:3].
That marriage comes after a haraam relationship, but the relationship did not go as far as zina, such as kissing, touching and other haraam actions that are less serious than zina. In this case the marriage is valid, because it cannot be said of those who fell into this haraam relationship that they committed zina.
For more information please see the answer to question no. 106288.
And Allah knows best.