The Enemy Within (Episode)
Stardate 1672.1: A transporter malfunction creates an evil Kirk.
In orbit of Alfa 117, the Enterprise experiences a momentary Transporter malfunction, caused by a magnetic ore accidentally brought aboard. Scotty checks the equipment, finds nothing wrong, and beams aboard Captain Kirk. After they leave the transporter room, a duplicate Kirk materializes. The malfunction has split the captain into two people, each physically identical but lacking mentally and emotionally. The "good" Kirk is compassionate, intelligent, and deliberate. The "bad" Kirk is violent, amoral, and savage.
An animal beamed aboard the Enterprise shortly thereafter is divided into two creatures as well—and after Yeoman Rand accuses the captain of assaulting her, Spock realizes the same has happened to Kirk. The transporter malfunction must be repaired shortly or a stranded landing party, led by Sulu, will freeze to death on the planet's surface.
The captain, meanwhile, is dying—neither half can survive alone. Scotty rigs the transporter to run through the impulse drive, and after capturing the "bad" Kirk, beams both captains down—and back as a single person. The restored Kirk then orders the landing party rescued.