Stuck front derailleur
Often while mountain biking a twig or rock will get stuck between the swing arms on your front derailleur. This effectively locks the derailleur in place until the rock/twig works itself out. 

If it happens again, stop and examine the derailleur. Generally you can't see the obstruction while you're riding.