Yes, that is still sinful.
God may want you to learn to deal with temptations in a healthy way and masturbating is not a healthy way to deal with them.
My advice is to not fight the thoughts, but just recognize them, accept them, and gently redirect yourself to something else. If that doesn’t work, say Hail Mary’s until the temptation passes. If it takes hours, then spend hours saying Hail Mary’s.
Masturbating to relieve lustful thoughts is like committing theft to relieve envious thoughts. You’ve replaced a sin with an even bigger one.
Also you will create the habit of masturbating to deal with those thoughts. Your body will learn that certain thoughts lead to dopamine release and sexual pleasure so it will send you those thoughts even more often, because it wants the rush and high associated sexual release.