What is the best way to stretch my hamstrings?
I predict that there are some "missing pieces" in the organization of your movement. Your brain and nervous system control your movement experience. In order to have freedom from pain and increase your flexibility you need more information/options for your brain. You need to become aware of what you ARE doing/moving and what you are NOT doing/moving. And you need to be gentle with yourself.
For starters I would STOP trying to stretch your hamstrings since you have probably been doing that and it sounds like it is not working for you. In fact, stretching to a point of pain is just teaching your brain that it hurts to move in that direction. That pain is sending a signal to your brain to protect your hamstring. This protecting signal will reinforce the tightening. A dangerous cycle!!!!
I would recommend finding practitioners of NeuroMovement® or the Feldenkrais Method. Check if they might have class in your area. I have free consultations, personalized lessons, local classes and on-line lessons and classes.