I find the following things help me to sleep when I am feeling anxious:
Before I get into bed, I write a list of all my worries on a piece of paper and leave it where I will see it in the morning. That way I know I can safely fall asleep without the risk of forgetting overnight anything I am worrying about. If I didn't write it all down, I would then have the added worry that by morning I may have forgotten something and consequently I would lie awake for a long time reciting my list of worries in my head to make sure I didn't forget them. (Ssssh, don't tell your OCD this but by morning your list of worries probably won't seem so daunting because you won't have fretted about them while you were asleep and so your anxiety will have faded and you will have regained a more rational perspective.)
If you regularly suffer from insomnia or nightmares, you will probably regard your bed as an enemy and you will dread night times. Try to turn it round so that you come to view your bed as a friend and look forward to night times. You could buy yourself a delicious fruit juice drink (something really special like Robinsons kiwi fruit & strawberry squash with no added sugar*) and ration yourself to only ever drinking it at night. Take a glass of it to bed with you and treat yourself to a sip of it intermittently throughout the night. Or if that's not your thing, commit yourself to only ever listening to your favourite type of music at night time and take an MP3 or iPod to bed with you. You mustn't drink that juice or listen to that music during the day - you must reserve it as a special treat for night times.
If you suffer from insomnia, brace yourself each evening for not getting any sleep at all during the coming night. Then after you go to bed, if you find yourself still awake after 2 hours of tossing and turning, you won't start worrying about all the sleep you are missing, since you weren't expecting to get any sleep in the first place. On the other hand, if you go to bed hoping to sleep well and then you end up still awake after 2 hours, the realisation that you're not falling asleep quickly will only vex you further and create more tension that will keep you awake longer.
If you get to the stage where you are lying in bed in the middle of the night feeling very tired but not sleepy, get yourself into a comfortable position (as snug as a bug in a rug as my old pa used to say to me when I was knee-high to a grasshoppper) and close your eyes. Then concentrate hard on keeping yourself from falling asleep! Keep your body still and use only your thoughts to try to keep your mind alert and avoid losing consciousness. It works for me everytime.
I hope you find this helpful.
* I suggest a drink without added sugar to avoid tooth decay from not brushing your teeth after taking a swig of it!