Pain is not a bad thing—the good pain of a safe stretch, that is. In fact, putting up with a bit of discomfort will increase your flexibility. You may be tempted to pull back from a stretch, especially in a pose you're not used to. But instead of coming out of the pose at the slightest hint of discomfort, bear with it. It's only by holding the pose that you'll coax your muscles to lengthen. You know from experience you'll feel better afterward, and the longer you hold the pose (safely, of course), the easier it will be next time.
Don't try to speed up the process by going too far too quickly, though. If you're extremely uncomfortable, you won't be able to hold the pose very long or relax into the stretch. So back off until the pain is bearable and hold it there. It's better to start off carefully and move forward rather than going too far and pulling back.
Anytime you feel sharp pain, come out of the pose immediately. And if you feel sharp pain in that area the next day, it means you went too far and hurt yourself. It's important to be very aware of what's going on in your body so you can find the right balance between stretching too little and stretching too much. At that point, at your edge, you'll be able to gain your maximum flexibility.
Once an asana becomes easy for you, try to either intensify it or seek out new poses that you find challenging. That way, you'll continue to increase your flexibility where you need it most.