In mountain biking, it's those deadly climbs that separate "the best from the rest". Here is how to get to the top first.
This one should be obvious, who ever can pedal the fastest will get to the top first, 9 out of 10 times. When you train make sure your route takes a couple passes at your towns "heart attack hill". Weight training will help, but will not build your endurance as much as riding your bike a lot.
Use Your Whole Body
Pulling up on your bar ends will give you the extra torque that will extend your pedalling power, especially on hills. Bar ends allow for more steering power, as your hands are spaced farther apart. After all, that's why they're there: for the hills. Also, lifting off of your seat to crank your frame back and forth as you pedal spreads the work out between your muscle groups and gives you more power at the expense of more effort.
Learn when to sit down and when to stand up. If the ground is loose go for more traction and sit down. Standing up will give you more power but may cause you rear wheel to slip on loose terrain. Also if you are trying to conserve energy just granny-gear it and sit down.
If you encounter a hill that it simply to steep to bike up, don't waste time trying, hop off and run up it. There are generally two different ways to run your bike up. If you are strong and you have a light bike you should carry your bike. Put your right hand on the cross bar and your left on the handle bar, now lift the bike up so it is almost resting on your shoulder. Another way is to simply leave your hands on the handle bars and run beside your bike.
When You Get to the Top
Just 'cause you are at the top doesn't mean it's time to pack up. In fact, putting in a few more good, hard strokes at the top means that you can take it easy on the descent as you coast past those who didn't give it that extra push at the top. As gravity magnifies your pedalling effort on a descent more than any other type of terrain, the single most important thing to do is pedal.
In short, sprinty races, you want to gear as hard as you can on the uphills to pedal and pass like mad. However, in longer races the best strategy is to gear easy, conserving your energy for the downhill. Also, especially if you have poor shifters, you should try to gear in advance for the upcoming hill, to avoid torquing heavily while shifting. When the hill gets steeper half way up, or you just get tired, your rate of pedalling will drop so don't hesitate to gear down to maintain a cadence of 1 to 1.5 revolutions per second for most efficient pedalling.
Climbing should be a balancing act. Keep tuning the distribution of weight between you wheels; if your rear wheel loses traction, slide back, and if your front wheel lifts up or needs steering traction, lean on your arms or slide forward. Especially when climbing out of the saddle, it is all too easy to lean forward and take the weight off the rear wheel just when it needs it, resulting in spinout and bogging down -- bend at your waist when standing to avoid this. Maintain constant traction and ground contact with both wheels.