Star Trek: The Enemy Within

On stardate 1672.1, the Federation starship USS Enterprise NCC 1701, under the command of Captain James T. Kirk, is on a geological exploration of the planet Alpha 177. Geological Technician Fisher falls from an embankment and injures his hand. He is immediately beamed back to the Enterprise for medical treatment. During the beamup, the transporter system behaves oddly. Nearly losing the technician, Mr. Scott immediately checks over the transporter equipment, but finds nothing wrong. He only notices magnetic dust from some ore samples covering Fisher's uniform when the technician materializes. Scotty orders him to have the uniform decontaminated.
Soon afterward, Captain Kirk beams back to the ship. The transporter seems to work smoothly, but Kirk feels disoriented. Scotty escorts him out of the room, leaving it empty. A moment later, a second Captain Kirk materializes on the transporter pad and no one is aware of his arrival. This Kirk is the "other half" of the Captain's split persona: a physical manifestation of his more selfish and evil qualities.
The first thing the "evil" Kirk does is head to Sickbay, where he demands a bottle of Saurian brandy from Dr. Leonard McCoy. McCoy doesn't understand this sudden, aggressive mood swing.
Back in the transporter room, Scotty beams up an animal specimen from the landing party, which appears to be a small, horned, dog-like creature. Two "dogs", however, arrive on the transporter pads. One is extremely vicious, while the other is very timid, yet both look identical. Confirming that the team only beamed one animal to the ship, Scotty realizes that something is very wrong with the transporter system. He is forced to strand the remaining landing party (including Lt. Sulu) on the planet until further notice.
Meanwhile, the evil Kirk, appearing drunk and disorderly, enters the quarters of Yeoman Janice Rand and lies in wait for her. When she arrives, he grabs and assaults her. She manages to fight back, scratching his face with her sharp fingernails, and then tries to escape. She cries out for Crewman Fisher to call Mr. Spock. Unfortunately, the evil Kirk incapacitates Fisher before he can help. Simultaneously, elsewhere on the ship, the good Captain Kirk begins to show signs of weakness, apparently losing his ability to make decisions and give orders, the so-called "power of command".
The evil Kirk acquires a phaser from a crewman, whom he also incapacitates, and then hides in the lower levels of the ship. Anticipating his moves, the good Kirk finds the evil Kirk on the Engineering Deck, and Spock disables the latter with a Vulcan nerve pinch. Spock is unsure how to proceed until he observes the evil Kirk showing signs of fatigue, which indicates that he may be dying.
It is quickly surmised that neither Kirk can survive for long in his separated state. Time is running out not only for the Kirks, but also for the stranded landing party, the members of which are slowly freezing to death as night falls on Alpha 177.
Scotty reports that the transporter unit ionizer is damaged and would normally take a week to repair; however, he and Spock rig up a connection to power the transporter from the ship's impulse drive. They recombine the dog-creature, but it dies as a result of the strain. Not giving up hope, Scotty continues to work on the problem.
In the meantime, the good Kirk releases his opposite's bindings in Sickbay when the evil Kirk promises not to fight back. However, the opposite does just that: he overpowers the good Kirk and rushes off to the bridge, where he orders the ship to leave orbit. The good Kirk follows and confronts him. The evil Kirk soon collapses from the strain. Good Kirk takes him to the transporter room. With fingers crossed, Spock dematerializes both Kirks, and finally a single Kirk returns. Demonstrating that his power of command has returned, along with his intelligence and compassion, Kirk's first words are: "Get those men aboard fast." The landing party members are beamed up, who, aside from a "little" exposure and frostbite, are fine.
Back on the bridge, Kirk is himself once again. He tells Spock: "Thank you, Mr. Spock-- from both of us." When asked what to tell the crew, Kirk says that the intruder is back where he belongs and to leave it at that.