I was at a conference in Chicago a good many years ago when I decided to do a little stretch one morning. Naively I tried to touch my toes, which turned out to be the worst idea I'd had in a long time as I overstretched something in my lower back and now I couldn't stand up straight without pain. I'd damaged back before I knew instantly that I was in a for a very painful few days at the very least.
I no longer try to touch my toes!
Anyway, years later I've learnt a lot about stretching and I'm much more careful these days. One of the key principles has to be stretch slowly and stretch progressively. Muscles don't like to be wrenched into a new length. They will respond and contract to protect themselves.
If you haven't done much stretching, and your suffering with inflexibility, then don't try to go from stiff to supple in one session. Plot your course and listen to your body. You can even keep a simple chart of how your range is changing. For example, you could estimate the degree of flexion you can get at your hip and see how it improves over the course of a week or month with regular stretching.
And if slow is the first principle, then doing the stretch properly has to be second if not equal first. I see poorly executed stretching all the time. Understanding what your trying to stretch and how to stretch it will bring better results long term. It might look impressive that you can get your leg up on the railing at hip height, but if you end up curling your back while trying to stretch your hamstrings, it's not going to work. Pick a bench, and use your body mechanics more efficiently!
So, stretch slowly, stretch specifically, don't overstretch, do it properly and do it progressively.