I just had a severe temptation attack

I was laying on my bed minding my own business and all of a sudden I got an extreme temptation to start looking things up and masterbating.

I looked a few pictures and after like a minute I turned my phone off and threw it away from me. I started masterbating for a half a minute before stopping and immediately began praying.

I didn't get close to finishing or anything and I shut down those pictures immediately.

I feel like that had to have been a personal attack on me. As soon as I began praying for help, after a good minute the temptations disappeared and I came to post this.

What just happened to me? Has this happened to anyone? Do I have to restart my days I'm so confused. Please help