Testicular torsion occurs when a testicle rotates, twisting the spermatic cord that brings blood to the scrotum. The reduced blood flow causes sudden and often severe pain and swelling.