I have always felt that muscle pain can be relieved by stretching in the long term. The warming and stretching of muscles not generally used everyday alleviates and tension and tightness and over time will reduce chronic pain. Letting your muscles rest and not overworking them can also relieve the pain.
Some stretches, such as Warrior II, stretch the muscles in the quadriceps which can help with knee/joint pain as well.
Getting blood flow to the muscles is important for healing. Stretching/Yoga allows blood access to these areas by using and opening them through various poses.
Short term, there are many balms, medications and topical solutions that can aid in relief of muscle pain and soreness.