Geckos are nature's elite climbers. Their remarkable climbing feats have been attributed to specialized feet with hairy toes that uncurl and peel in milliseconds. Here, we report that the secret to the gecko s arboreal acrobatics includes an active tail. We examine the tail s role during rapid climbing, aerial descent, and gliding. We show that a gecko s tail functions as an emergency fifth leg to prevent falling during rapid climbing. A response initiated by slipping causes the tail tip to push against the vertical surface, thereby preventing pitch-back of the head and upper body. When pitch-back cannot be prevented, geckos avoid falling by placing their tail in a posture similar to a bicycle s kickstand. Should a gecko fall with its back to the ground, a swing of its tail induces the most rapid, zero-angular momentum air-righting response yet measured. Once righted to a sprawled gliding posture, circular tail movements control yaw and pitch as the gecko descends. Our results suggest that large, active tails can function as effective control appendages. These results have provided biological inspiration for the design of an active tail on a climbing robot, and we anticipate their use in small, unmanned gliding vehicles and multisegment spacecraft.