Initially, Islam encourages us to have strict control on our sexual organs except for things that Allah made permissible. Allah says: (Those who guard their sexual organs except with their spouses or those whom their right hands possess, for (with regard to them) they are without blame. But those who crave something beyond that are transgressors) (Al-Mu’mun 23: 5-7)
Masturbation for both males and females is haraam (forbidden) in Islam based on the verses (23: 5-7). Although it is haram, but it cannot be considered as a grave sin as zina. In the books of Sunnah we read that ‘Abd Allah Ibn Mas’ud said, “We were with the Prophet while we were young and had no wealth whatsoever. So, Allah’s Messenger said, “O young people! Whoever among you can marry, should marry, because it helps him lower his gaze and guard his modesty (i.e. his private parts from committing illegal sexual intercourse etc.), and whoever is not able to marry, should fast, as fasting diminishes his sexual power.
The hadith orders men who are not able to marry to fast despite the hardship encountered in doing so, and not to masturbate despite the ease with which it can be done. What you have done, although it is haram, but it cannot reach the status of committing zina. The Prophet ( peace and blessings be upon him) warned us against such things. He said: (Eyes would commit adultery through looking, tongue would commit zina by talking, ears would commit zina by hearing and the sexual organ would accept all of that or refuse it) Reported by al-Imam Muslim. Zina in the Hadith is not the technical meaning of the word but just to show the gravity of zina and everything (such as masturbation) that would lead to it.
Brother, you need to make a since repentance. 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 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.