All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger. We ask Allaah to exalt his mention as well as that of his family and all his companions.
You have to know, dear brother, that there is no disease except that there is a treatment and a cure for it. The depression that you are suffering could be from an unexpected matter or an effect caused by long thoughts on some problems that you faced or because of exaggerated feelings towards some behaviour that you encountered, or due to other reasons. This disease could also be a result of some physical diseases for which one has to refer to trustworthy specialists in the field.
The best method in treating this kind of disease, in addition to the medicines you are using, is to strengthen one's faith and comfort the heart by the mention of Allaah.
In order to achieve this, one should do the following:
1. Recite Allaah's Book and pondering over it.
2. Perform supererogatory acts of worship after performing the obligatory ones in order to get near to Allaah.
3. Endeavour to continuously mention Allaah.
4. Love Allaah more than loving your own self.
5. Ponder over the signs of Allaah in this universe, and on His Attributes and Names.
6. Keep company with righteous people and attend places of virtue like mosques and the like.
If you follow these steps that we advised you to do then, we hope that you will be cured, by Allaah Permission. You know better about your own self, so you should try to achieve what would benefit it, by seeking Allaah's Help and avoiding laziness.
As regards the sexual impotence that you have mentioned, and that you have no interest in your wife, this is a temporary matter and we hope that it will stop after being cured from your disease. So we advise you and your wife to be patient about this situation. Indeed, there are higher objectives in marital life besides sexually enjoying each other.
Finally, it should be noted that masturbation is forbidden and whoever does it is sinful, so you should refrain from it. For more benefit on this regard and the ruling on masturbation please refer to Fatwa: 81150.
Allaah knows best.