Negative thoughts & fear are hard to face and get harder when they start affecting sleep. It is a negative & disruptive cycle you have been going through.
There could be physiological or psychological factors acting behind your anxiety. Through the way you have mentioned it, I am interpreting that you start with negative thoughts, which when intensified leads to fear followed by emotional reaction in your body which disturb your sleep and disturbed sleep leads to more anxiety.
Short term solution would be to try and stop the flow of thoughts once you are aware of them however if they intensify and lead to bodily/ emotional discomfort, you will have to try different ways of soothing your bodily sensations and emotions such as relaxation techniques, soothing music, taking a shower, taking a walk etc. Medicine may come handy here.
Long term solution would be to make an effort to understand the cause & tackle it rather than trying to address symptoms. Your negative thoughts, fear and anxiety have been arising from within you as a response to situations or otherwise. Stand up & address every thought or every fear for which a professional(psychiatrist, psychologist) could be of assistance.
Hope you start taking control of your life and addressing the issues soon. Take Care.
Next Steps
Rule out the Physiological source of Disturbance followed by Taking Measures to address Psychological Functioning