PloddingLady - no amount of stretching or warm up/ cool down is going to offset muscle stiffness if you've just exerted yourself well beyond the limits of what your training has prepared you for. I'm not 'telling you off' (as if I could!), just trying to help you have realistic expectations.
Some stretching may help, as will eating/ drinking a decent amount of carbohydrates & protein as soon as you can after exercising vigorously (no more than a 1 hour delay, but the sooner the better). The body is very responsive to using these nutrients after a hard workout, but the effect goes away quickly.
The pain itself comes from all the micro-injuries in the muscle fibres caused by the hard exercise. This is normal. Muscles grow by being slightly damaged, then rebuilding to be slightly stronger. If you stretch the muscles hard in their damaged state, you create muscle tears which are very painful and will prevent further exercise. So the trick is to exercise just hard enough to stress the muscles, but not so much as to injure them.
Muscles are repaired by blood flow, which brings nutrients and oxygen to the damaged tissues (hence the importance of good post-exercise nutrition). Very gentle exercise will stimulate blood flow but not stress the muscles. This is often referred to as a recovery run. Run/ jog/ walk at a pace where your heart rate goes up a bit but you can easily maintain a conversation. Normally one or two of these will ease away the pain you are feeling. I ran a marathon on Sunday and did a 1km run on Monday and a 6k run today. Legs are feeling much better now.
Good luck, and try to have a more consistent connection between your training effort and what you do in your races. Running tends to be more fun when you don't have so much pain afterwards (I'm repeating this for my own benefit too).