Marrying someone one once had premarital relations with can be dealt with through the following two points:

  1. Islam’s stance on illegal relations between a boy and a girl
  2. Could this boy marry this girl?

As for the first point, it is known that establishing an illegal relation between a boy and a girl is a grave sin. Zina is one of the major sins that deserve severe punishment from Allah Almighty. However, one who engaged himself or herself in such a haram relation should seriously repent to Allah, stop all evil practices, feel remorse for his sins, resolve not to do such a sin again, and do as much as he or she can of good deeds.

This repentant brother or sister should never lose hope of gaining Allah’s mercy: “Say: ‘O my Servants who have transgressed against their souls! Despair not of the Mercy of Allah: for Allah forgives all sins: for He is Oft-Forgiving, Most Merciful.'” (Az-Zumar: 53) “Allah accepts the repentance of those who do evil in ignorance and repent soon afterwards; to them will Allah turn in mercy: For Allah is full of knowledge and wisdom.” (An-Nisa’: 17)
In this regard, Sheikh Ahmad Kutty, a senior lecturer and an Islamic scholar at the Islamic Institute of Toronto, Ontario, Canada, states:
“If one has extra martial affairs with a man/woman and then he repented sincerely for his/her heinous sin, then he/she will be forgiven.
allah says, “Didn’t they know that it is Allah who accepts repentance of His servants and forgives sins?” (At-Tawbah: 104). The Prophet (peace and blessings be upon him) said, “Allah accepts the repentance of a person as long as death has not reached his collar bone (i.e., as long as it is not done in the last pangs of death ).”
Sincere repentance, however, is not simply saying, “Lord, forgive me”, “I ask forgiveness of Allah.” Sincere repentance involves experiencing within oneself a profound sense of guilt for having disobeyed Allah and for the terrible sin one has committed. Secondly, one should totally refrain from approaching that sin as well as from such associations and circumstances that may led him/her to it; thirdly, one must be resolved never to repeat the same in the future, and finally, one must also do whatever he/she can to wipe out the past sins by engaging in good works as much as possible.
Once the above procedures are followed, we can look forward to Allah’s forgiveness for He is certainly All-Merciful and All-Forgiving.
having said this, it is important to point out that if a person has sinned in the past, he/she must continue to be vigilant, and remember that Allah Sees all that we do. The person should try to visualize heaven and hell as if they are in front of them. That is the only way to check one’s carnal desires .”

As for the question of marriage, if both the boy and the girl—who committed this grave sin—repented and changed their life style, then they could marry.

In this context, Sheikh Ahmad Kutty state:

“As far as marrying a man or a woman who had been guilty of fornication, we are not allowed to do that unless and until we have clearly ascertained that they have repented and changed their life style.
allah says in the Qur’an: “Good spouses are for good ones, and vile ones for vile ones, and it has been declared haram for the believers.” (An-Nur: 3)
however, if a person has repented and lived a good life after repentance for some time, it is allowed to contract marriage with him or her. The Prophet (peace and blessings be upon him) says: “The one who has repented sincerely is like one who has never sinned.”
allah also says, after mentioning the grievous sin of fornication and its terrible punishment: “Except those who have repented and cherished true faith and have done good works, such are the ones whose bad deeds shall be turned into good deeds by Allah. Verily Allah is Forgiving and Merciful.” (Al-Furqan: 70)”