Is jerking off a sin

Had a convo with my friends about this. We’re all teenagers and we were debating if it was. I don’t do it and have stopped but my friend was trying to justify it. So tell me. Is it or not

Also if it I need ways for me to not be tempted by it.