A locust placed upside down on a flat surface uses a predictable sequence of leg movements to right itself. To analyse this behaviour, we made use of a naturally occurring state of quiescence (thanatosis) to position locusts in a standardised upside-down position from which they spontaneously right themselves. Locusts grasped around the pronotum enter a state of thanatosis during which the limbs can be manipulated into particular postures, where they remain, and the animal can be placed upside down on the ground. When released, thanatosis lasts 4-456 s (mean 73 s) before the animal suddenly becomes active again and rights itself within a further 600 ms. Thanatosis is characterised by very low levels of leg motor activity. During righting, one hind leg provides most of the downward force against the ground that rolls the body around a longitudinal axis towards the other side. The driving force is produced by femoral levation (relative to the body) at the trochanter and by tibial extension. As the animal rolls over, the hind leg on the other side is also levated at the trochanter, so that it does not obstruct the movement. The forelegs and middle legs are not required for successful righting but they can help initially to tip the locust to one side, and at the end of the movement they help stop the roll as the animal turns upright. Individual locusts have a preferred righting direction but can, nevertheless, roll to either side. Locusts falling upside down through the air use both passive and active mechanisms to right themselves before they land. Without active movements, falling locusts tend to rotate into an upright position, but most locusts extend their hind leg tibiae and/or spread their wings, which increases the success of mid-air righting from 28 to 49 % when falling from 30 cm. The rapid and reliable righting behaviour of locusts reduces the time spent in a vulnerable upside-down position. Their narrow body geometry, large hind legs, which can generate substantial dorsally directed force, and the particular patterns of coordinated movements of the legs on both sides of the body are the key features that permit locusts to right themselves effectively. The reliability of autonomous multi-legged robots may be enhanced by incorporating these features into their design.