Stardate 5906.4: The Enterprise orbits an uninhabitable planet with a surface of molten lava, while Spock picks up carbon-based life forms. They detect advanced power readings but there's no response to their hailing frequencies. Kirk decides to call off the investigation but the ship is suddenly scanned by the inhabitants below. A glowing figure then appears before them and coalesces into the image of… Abraham Lincoln.
Spock believes it's an illusion but Lincoln asks to be brought on board so they can beam him aboard in twelve minutes when they are above his position on the planet. As they look on, a habitable Earth-type environment appears on the planet, 1,000 square kilometers and completely Earth-like. The Enterprise arrives over it at Lincoln's predicted time, and Kirk calls for a security team to present full Presidential honors while ordering full dress uniforms.
As they prepare to beam Lincoln aboard, Scotty and Spock detect a rocklike life form which transforms into human. They beam aboard Lincoln, who comes to attention at the music and is puzzled by the concept of taped music. He is equally ignorant of how the transporter works but seems otherwise knowledgeable of the ship and crew. McCoy confirms that Lincoln is human and Kirk escorts him to the bridge. Scotty admits he isn't sure if the rocklike alien was Lincoln, or someone nearby.
On the bridge Lincoln apologizes to Uhura to calling her a "negress," but also can recite Vulcan philosophy even though even he isn't aware how he knows the information. He asserts that on the planet a famous Vulcan is also on the planet and Kirk and Spock are invited. While Kirk has him go on a tour of the engineering room, he meets with the senior officers. While they all agree that "Lincoln" can't possibly be real, he is a personal hero of Kirk's and might tempt him to beam down to the planet with Spock. Kirk agrees to go down, believing it is some form of alien communication, and overrides McCoy's and Scotty's objections.
Upon arriving on the planet, Kirk and Spock discover that their phasers and tricorders don't work, and their communicators fail to function. Aboard the Enterprise, the power systems start to fluctuate. Lincoln insists he is Lincoln, and a new person arrives: Surak, the greatest of all who lived on Vulcan. Spock is clearly taken aback and only greets him as the image of Surak. They're interrupted when a rock-like creature appears and offers them greeting to the planet of Excalbia. It claims they have been invited as friends to participate in their "play." The rock being then calls forth four humanoids: Genghis Khan, Colonel Green, Zora, and the Klingon Kahless the Unforgettable: four of the evil figures in known history.
The Enterprise is suffering from a massive power loss as the Excalbian, Yarnek, permits them to watch the "experiment" on the view screen. There's nothing they can do to aid Kirk and Spock, except determine they're apparently humanoid life forms.
Yarnek offers them the chance to fabricate any weapons they wish as they battle the side of "evil," as the Excalbians test which of the two philosophies is more powerful. Kirk refuses to fight but Yarnek says he will have to decide otherwise. Colonel Green approaches Kirk and suggests they call a halt to hostilities and try to find a way to escape. Green admits he can't remember where he came from or how he got to Excalbia, but he wants to return there. He proposes an alliance against Yarnek, but Kirk notes that Green often struck at his enemies in the middle of negotiations. Green's evil allies attack but Kirk and the others managed to drive them off. Yarnek expresses his disappointment that they refuse the honor of becoming their teachers. Kirk tries to attack him and only burns his hand, but Yarnek lets him contact the Enterprise Scotty gives him an update that the matter/anti-matter are in red-zone proximity and they have four hours until the ship explodes. Yarnek then cuts off communication again and notes to save the ship, they have to win.
While Green and his forces improvise weapons, Kirk finds a defensible position and proposes they scout out the enemy forces while making their own weapons. Spock and Surak suggest that they find a peaceful approach, and Surak insists that they should not fight and refuses to harm others. Spock backs the captain but argues that Surak should get the choice. Surak offers to go and offer peace, since he is not a warrior in any case. Kirk lets him go but starts putting together the weapons in case he fails.
Surak approaches the enemy camp where Green demands to know what he wants. Green talks with him but sends Kahless and Khan around to take him prisoner.
Back at the camp, Kirk and the others are preparing weapons when they hear a scream from the opposing camp. Surak calls out for help but Spock insists that a Vulcan wouldn't cry out in pain or give in to torture. Kirk is tempted to go after him and Lincoln suggests they pretend to be goaded into action and Kirk and Spock conduct a frontal assault while Lincoln sneaks around to the rear and frees Surak.
Kirk and Spock attack from the front but Green notices that Lincoln is missing. Lincoln sneaks around the back and spots the seemingly unconscious Surak. However when he tries to free him he discovers that he's dead. Green and Kahless have realized it's a trick and come up behind him.
At the front of the camp, Lincoln staggers out, a spear in his back, and collapses. Green and the others launch an attack and engage in hand-to-hand. Khan and Zora run away while Kahless falls on his spear. Kirk goes after Green and ends up impaling him with his own weapon. Yarnek appears to congratulate them but admits it doesn't understand any difference between the philosophies of good and evil. It releases the Enterprise and says they had the right through the need to know new things.
Back on board the Enterprise they watch as the earth-area on Excalbia disappears back into the lava. Spock surmises the Excalbians scanned their minds and used their fellow creatures as source matter to make Lincoln and the others. Kirk admits it's hard to see Lincoln die a second time and notes there is still much of Lincoln and Surak's work to be done.