Deuteronomy 23
9
When you are encamped against your enemies, keep away from everything impure.
10
If one of your men is unclean because of a nocturnal emission, he is to go outside the camp and stay there.
11
But as evening approaches he is to wash himself, and at sunset he may return to the camp.
12
Designate a place outside the camp where you can go to relieve yourself.
13
As part of your equipment have something to dig with, and when you relieve yourself, dig a hole and cover up your excrement.
14
For the LORD your God moves about in your camp to protect you and to deliver your enemies to you. Your camp must be holy, so that he will not see among you anything indecent and turn away from you.
Whenever we are engaged in something that is sexual, I believe God always turns away. I don't have to state the obvious...masturbation is something that you do in private. I don't think that the Lord peeks in when a married couple is in the midst of passion tho either.
Here, in this passage, I'm not sure the bible is clear on the circumstance. When it speaks of a nocternal emission, it's not clear if that is something like a wet dream (excuse my forwardness) or if it is masturbation. Either way, the man was expected to leave the camp because it was a Holy place and not to be defiled.
If it is sin, so is lust a sin. Sometimes lust occurs when you least expect it. A particular thought about someone, a fleeting image...hard to put a harness on those things.
Sometimes things totally nonsexual will strike a cord and bring on unexpected responses.
If I may be so bold...I would've really liked the bible to have said...
Commandment 11:
Do Not Masturbate...
( of course, I am wishing that purely for the purpose of answering any questions
others may have on the subject

)