By taking your time and not rushing to the act of masturbation itself, you may win yourself enough time to come down from the initial urge to masturbate.
Over time you will train your body and yourself to not associate the instance of arousal with the act of masturbation.