Knee pain is a common complaint of mountain bikers, because the sport is so physically demanding. Knee pain can develop for a variety of reasons. Most pain can be alleviated by making minor adjustments in the bike's setup or your riding style. Warming up before riding on trails, and stretching when you are done may help prevent knee stiffness and muscle pain.
Terrain
Mountain biking terrain is notoriously rough. Hills, jumps, rocks, roots and dirt tracks can all challenge the mountain biker and his body. The knees act as the primary shock absorber when you are navigating rough terrain on a bicycle. Standing up on the pedals as you steer your bike can make the rough ride more enjoyable. If steep hills cause pain in your knees, try shifting into an easier gear, or simply walking up the steeper hills.
The Right Bike
Choosing a mountain bike appropriate for your height and weight may be the best way to protect your knees. Visit a local bike shop and get professionally fitted to make sure you are riding a bike that is the correct size. The bike shop should be able to suggest frame and suspension types to match the terrain and your riding style.
Saddle Height
Have your local bike shop check that your saddle is set at the correct height. For reference, when you are at the bottom of your pedal stroke, your knee should not be straight, but should have at least 15 degrees of bend. When you pedaling, if you are rocking back in forth in the saddle your seat is too high. A seat that is too high can be detrimental to the knees; you are hyper-extending your knee with each pedal stroke. Meanwhile, low seats are very energy inefficient, providing less power and increased stress on your knees with each stroke.
Saddle Angle
The saddle should be centered and level. Center the seat post on the rails on the underside of the saddle. Make sure the seat is level. Use a carpenter's level and line it up with a horizontal line you know is straight, such as a brick wall or tabletop. A forward-tilted seat is a common cause of knee pain in mountain bikers. A forward angle places more stress on the knees, which over time may lead to knee pain.
Treatment
If you experience knee pain while mountain biking, take some time off to rest. If you can't walk due to knee pain, see your doctor. Nagging pain can develop into a long-term knee injury.
Note – This information has been taken from different internet sources.