How Can I Overcome My Habit of Masturbation?

How can I overcome my habit of masturbation?
May Allah reward your efforts in seeking a cure and also in seeking guidance.

Don’t Give Up

First of all, do not give up! Keep trying to defeat this addiction. In order to achieve that, it will require continued efforts by yourself. Fasting, getting married, and abandoning the internet to the extent you can helps. Being in good company, strengthening your faith by learning, studying, isolating yourself to be alone with Allah, and pondering death and the purpose of life will all help. However, what will not help is letting things be as they are with no real effort daily to alter your habits. If you are sincere and keeping striving, eventually, I am confident that you will leave this sin.
Allah mentions in the Quran, “As for those who strive for Us—We will guide them in Our ways. God is with the doers of good.” [Qur’an 29:69]
However, always keep repenting and making a new intention to strive to abandon this act.
It is wise to seek professional help if you see that this is seriously ruining your studies/work/family life etc. There is nothing wrong with taking the means to help your situation. Do it discreetly and seek help from the proper resources.
Meanwhile, you may also find the following beneficial;
[Imam] Yama Niazi
Checked and Approved by Shaykh Faraz Rabbani