Carpal tunnel syndrome occurs when the median nerve, which runs from the forearm into the hand, becomes compressed or irritated at the wrist. This compression can result from repetitive hand movements, wrist injury, or underlying conditions like arthritis.