Question:
Every time I pray Salah. Very evil thoughts come into my head. Do these invalidate my Salah?
Answer:
In the name of Allah, Most Compassionate, Most Mercifuf
Salah will be valid even if the thoughts are intentional, however, this will result in reduction of thawab and if the thoughts came unintentionally and you tried to thwart them you will get thawab for your efforts.
A hadith in Muslim says:
“Verily Allah has forgiven my Ummah for the thoughts their minds whisper as long as they don’t practice (on the thougts) or put them in words”