He is a student living in Denmark and he is suffering with the secret habit
Question

                I am a 24 yr old from India studying in Denmark , alhamdulillah I don’t miss any prayers prescribed to us and when I go out I don’t look at women, neither I watch movies except two or three in a year nor do I have relations with any girl, but I used to masturbate in teenage. When I go to sleep I recite all dua, s prescribed by sunnah and try to sleep in the state of wudhu, at least once in a week I myself don’t know I wakeup in the middle of the night and start masturbating or I visit pornographic websites until I fulfill my desire, my intention was not even 1% to do these things in the middle of the night while going to bed but in the day time these whims and desires cross my mind. In the next morning I feel regretful of what I did last night and every time I used to correct it for some days again the same thing happens, this is the most regretful and the most sad period since I born sheikh because this is continuing since 3 years and I don’t feel peace and satisfaction in my life, since I am disobeying Allah. Every time I do taubah to Allah and promise that I won’t go back to this habit, I break that promise. I have read your previous answers with regard to masturbation habits, but I would like from you little more specific answer to this question. I would be very grateful to you throughout my life, I also request you to do dua for me sheikh.
Praise be to Allah.On this site we have 
    discussed many issues to do with masturbation, and we have mentioned the 
    ruling on it, that it is haraam, as well as ways of protecting oneself 
    against it and ways of giving it up – see question no. 
    329. It seems that 
    you have read all of that, and that you want something that applies 
    specifically to you, so we will discuss some specific issues with you:
 -1-
The fact that you pray 
    regularly, are keen not to form relationships with girls, your determination 
    not to fall into this bad habit and your regret after doing it are all good 
    and will be included in the balance of your good deeds, in sha Allaah. We 
    encourage you to carry on with that and build on it, and do not give up. 
    Your faith has to continue to increase; do not give the shaytaan any 
    opportunity to harm you and make you feel that you are contradicting 
    yourself or stop you regretting and repenting, lest you become one of the 
    doomed. 
-2-
Do not add to this bad 
    habit other sins that will incur the wrath of your Lord, may He be glorified 
    and exalted. If your desire overwhelms your faith and reason, and leads you 
    to practice this bad habit, what is making you commit other sins that incur 
    the wrath of Allaah? What we mean is looking at corrupt websites. Fear 
    Allaah with regard to yourself and do not fan the flames of desire in your 
    heart by looking at haraam things or reading pornographic stories or other 
    things that provoke desire. There is no excuse for any of that because you 
    have control over whether you do it or not. 
-3-
Unfortunately you are 
    living in a permissive country and studying in a mixed environment, where 
    you see evil and immoral things which may cause you to fall into this habit. 
    There is no doubt that committing this sin is less serious than committing 
    zina, if we assume that you have the opportunity to commit this immoral 
    action and it is the matter of choosing between zina and masturbation. But 
    if you really want to rid yourself of this habit and other sins, then you 
    have to rid yourself of the things that provoke these desires, such as 
    living in a permissive country, looking at haraam things and mixing in 
    haraam ways. 
-4-
What we have mentioned in 
    our previous answers is sufficient for you and others who sincerely wish to 
    rid themselves of this habit. But we will tell you of two important things 
    which we hope will help you to rid yourself of this habit and other haraam 
    things: 
(i)
First of all, we ask you: 
    could you do this bad habit in front of your family and brothers? Could you 
    do it in front of your friends and neighbours? Could you do it in front of 
    any of the scholars or the Sahaabah? We are certain that your answer will 
    be: No, I could not do that, no matter what levels my desire reached. Is 
    that not the case? Well, do you know that you are doing it before the Lord 
    of the heavens and the earth?! Do you know that the Creator of the universe 
    can see you when you are doing it? Do you know that when you do it the noble 
    angels can see you? How can you regard Allaah as the least of those who can 
    see you? 
Who is most deserving that 
    you should feel shy before them – those from whom you conceal your action so 
    that they will not say bad things about you, or the One Who warns you of 
    punishment for your action? 
Allaah says (interpretation 
    of the meaning): 
“They may hide (their 
    crimes) from men, but they cannot hide (them) from Allaah; for He is with 
    them (by His Knowledge), when they plot by night in words that He does not 
    approve”
[al-Nisa’ 4:108]. 
Imam Ibn Jareer al-Tabari 
    (may Allaah have mercy on him) said: 
What Allaah means in the 
    words “They may hide (their crimes) from men” is that these people 
    who are fooling themselves conceal what they do of betrayal and sin “from 
    men” who could not do them any harm except saying bad things about them 
    because of what they do, if they find out about it. 
“but they cannot hide 
    (them) from Allaah” Who is watching them, and none of their deeds are 
    hidden from Him, and He is the One Who can punish and hasten the punishment; 
    He is the One before Whom they should feel shy, above all others, and He is 
    the One Who should be respected so that He will not see them do anything 
    that they would not like any of His creation to see them doing. 
“for He is with them (by 
    His Knowledge)” means: Allaah is watching them. 
Tafseer al-Tabari 
    (9/191) 
Shaykh ‘Abd al-Rahmaan 
    al-Sa’di (may Allaah have mercy on him) said: 
This is due to weakness of 
    faith and lack of certain belief, because in their case fear of other people 
    is greater than fear of Allaah, so they strive by both permissible and 
    forbidden means to make sure that they are not found out by other people, 
    but despite that they challenge Allaah by committing major sins and they did 
    not care that He sees them and that He is with them by His knowledge in all 
    their affairs, especially when they do that which does not please Him. 
Tafseer al-Sa’di 
    (p. 200) 
(ii)
You do not know when you 
    will die, do you? And you do not know in what condition you will die, do 
    you? Stop for a moment and think about it. What if Allaah were to take your 
    soul in death when you were doing this bad habit? Would this be a good end 
    or a bad one? What if you were to be raised from your grave when the last 
    thing you were doing is this habit? Perhaps you have heard the stories that 
    are widely propagated in words and images about those foolish girls whose 
    end came when they were committing evil actions. Who can guarantee that you 
    – or us – will have a good end? Who has any control over the manner and time 
    of death except Allaah? 
We hope that you will think 
    about what we have said to you, and ask your Lord with all sincerity to 
    cleanse your heart and physical faculties from sins and evils. It was 
    narrated from Abu Dharr in a hadeeth qudsi that the Prophet  (peace and 
    blessings of Allaah be upon him) said that Allaah said: “O My slaves, all of 
    you are astray except those whom I guide, so ask Me for guidance and I will 
    guide you.” Narrated by Muslim. 
So hasten to fill your time 
    with beneficial things and strive to keep company with righteous people who 
    can take care of you. Hasten to get married, for there is no permissible way 
    of fulfilling your desires except marriage. It is not essential for you to 
    have your parents’ permission. 
The Prophet  (peace and 
    blessings of Allaah be upon him) said: “O young men, whoever among you can 
    afford it, let him get married, for it is more effective in lowering the 
    gaze and guarding one’s chastity. And whoever cannot afford it, let him 
    fast, for it will be a shield for him.” 
Narrated by al-Bukhaari 
    (4778) and Muslim (1400) 
Imam al-Nawawi (may Allaah 
    have mercy on him) said: 
Whoever among you can 
    afford to get married, let him do so, and whoever cannot afford to get 
    married should fast so as to reduce his desire. Based on this the words are 
    addressed to youth who are the ones who usually desire women and cannot 
    avoid thinking of their physical desires. 
Sharh 
    Muslim (9173). 
Strive to save yourself. We 
    ask Allaah to enable you to do that which He loves and which pleases Him, 
    and to purify your heart and physical faculties, and to make you steadfast 
    in faith and certain belief, and to grant you a good end. 
See also the answer to 
    question no. 20229 for information on ways to help you lower your gaze; no. 
    20161 for information on solving the problem of desire; and 
    39768 where we 
    have mentioned the health effects of this habit on the body, mind, face and 
    memory, and ways of ridding oneself of this habit and avoiding it. 
And Allaah is the Source of 
    strength.