An ankle sprain occurs when the foot rolls or twists in an unnatural way, causing the ligaments to stretch beyond their normal range of motion. This stretching can lead to ligament damage and subsequent weakening.