The psoas major muscle flexes the thigh at the hip joint when the trunk is stabilized and flexes the trunk against gravity when the body is supine. It is innervated by anterior rami of nerves L1 to L3.