Crossed extensor reflex
The crossed extensor reflex or crossed extensor response or crossed extension reflex is a reflex in which the contralateral limb compensates for loss of support when the ipsilateral limb withdraws from painful stimulus in a withdrawal reflex. During a withdrawal reflex, the flexors in the withdrawing limb contract and the extensors relax, while in the other limb, the opposite occurs as part of the crossed extensor reflex. Besides shifting the body weight to the other side, the reflex pathway is also associated with leg coordination when walking by flexing muscle on one side, while extending muscle on  the other side. This crossed extensor response is properly part of the withdrawal reflex. An example of this is when a person steps on a nail: The leg that is stepping on the nail pulls away, while the other leg takes the weight of the whole body. The crossed extensor reflex is contralateral, meaning the reflex occurs on the opposite side of the body from the stimulus. To produce this reflex, branches of the afferent nerve fibers cross from the stimulated side of the body to the contralateral side of the spinal cord. There, they synapse with interneurons, which, in  turn, excite or inhibit alpha motor neurons to the muscles of the contralateral limb. In the ipsilateral leg (the one which steps on the nail), the flexors contract and the extensors relax to lift the leg from the ground. On the contralateral side (the one that bears all the weight), the flexors relax and the extensors contract to stiffen the leg since it must suddenly support the entire weight of the body. At the same time, signals travel up the spinal cord and cause contraction of the contralateral muscles of the hip and abdomen to shift the body’s center  of gravity over the extended leg. To a large extent, the coordination of all these muscles and maintenance of equilibrium is mediated by the cerebellum and cerebral cortex.