I can't believe someone asked this.
Based on your question you are gay, or bi, or curious, or all of these. Any of which are fine. If you were straight, you would have probably smacked your mate in the face or at the least explain that you have no interest in another man's junk. I do not even want to see my friends stuff- maybe you do, which is fine.
Would I do this for a friend. No. Also, I do not have any friends that want a man to jerk them off. You do. So your friend is clearly gay or bi- which is fine. Bottom line - he wants a man to jerk him off. This is clear - for him, it is okay for another man to fondle his junk. I could not perform with a man touching me, as women are awesome and I have no interest in other men.
If you want to stroke a man's junk, go for it. It is about you wanting to do it, not your friend in need. He can go without. But if you do do this, don't be suprised if he tries to get you to blow him- because he's so "helpless" and needs your help. When he's horny - and YOU will be making him horny- he'll beg you to do other stuff. Your friend wants you to do it, and if you do- he'll ask you to do it again and then he'll start pushing more boundaries. Because he's gay, and you will become a sexual outlet for him.
And clearly, this will absolutely destroy the friendship. Actually the friendship is already in question and may already be gone. But then again, you are asking the question in the first place so you may be interested in him. If you are actually confused, maybe you are young- I don't know, and are actually asking strangers for advice, I can honestly tell you this is a horrible idea, unless you want to date him and have a relationship with him. Which is totally fine, of course.
If you think you are still going to be friends with him after, you will not. Actually, he does not want to be your friend, you must know this. He wants you to perform sexual acts for him.
Do you really think a person can't go without jerking off for a few months? What type of bullshit excuse is that? If I had the option of going without, or having a guy jerk me off--- waiting is no problem, because I don't get hard for dudes.