Stardate 5693.2: The Enterprise arrives in an unsurveyed sector of space looking for a missing sister ship, the Defiant. Spock reports that space is "breaking up" while Scotty notes there's a drain on the engines. They spot the Defiant but it only barely registers on the sensors. They get within transporter range and Kirk, Spock, McCoy, and Chekov beam over in environmental suits. They arrive on the Defiant's bridge to find that the crew has killed each other.
The ship is still functioning and they try to locate the mutineers but Spock detects no life signs. McCoy and Chekov go to search other sections of the ship while the Defiant begins to drift. In sickbay, McCoy finds patients strapped to the beds and others who killed themselves, and Chekov finds other dead men in Engineering. Chekov is seized by a brief bout of dizziness then makes his way back to the bridge. As McCoy heads for the bridge he spots a corpse which is dematerializing, and determines the ship is dissolving. The Defiant begins to fade in and out while Scotty goes to work on the malfunctioning transporter. Spock warns that whatever is happening to the Defiant is beginning to happen to the Enterprise as well.
Kirk orders Scotty to beam them back but the engineering officer can only get three frequencies working. Kirk orders the others to beam over and they barely make it. Before Scotty can get a lock on Kirk, the Defiant disappears… taking the captain along with it.
Spock calculates the time until the next interphase period occurs, and they have two hours to wait. Scotty warns that with the power dropping, he'll be unable to hold the ship in place. Spock warns that if they disturb the local space then it will rupture the interphase. Spock explains to an irritable Chekov, who is suffering from headaches. The ensign goes berserk and they manage to subdue him, and McCoy and Spock conclude whatever drove the Defiant crew insane is starting to work on the Enterprise crew. Spock warns that they can't move out of the area until they recover Kirk, believing he was protected from the shock of interphase because he was in transport. The captain's suit only has a little over three hours' oxygen remaining.
An alien ship approaches the Enterprise and its commander establishes communications. The alien identifies itself as Commander Loskene of the Tholian Assembly. It insists they are in Tholian space and doesn't believe their story about the Defiant, but gives them time to make the recovery.
At the designated time, McCoy and Chapel work on a cure while Scotty tries to beam the captain aboard. The engineering officer can't get a fix and Sulu confirms the sensor readings have changed, due to the Tholian entry into the vicinity. The Tholians open fire, damaging the ship, and Spock refuses to leave the area, instead firing on the Tholian ship. They disable it and McCoy accuses Spock of failing to protect the crew but Spock stands by his decision.
Another Tholian ship arrives and refuses to accept their hail. The two ships briefly come together then begin to "spin" an energy web around the Enterprise. Spock determines that if they complete their "web" before they can complete repairs then they'll be destroyed.
Spock holds a memorial service for Kirk and then McCoy informs him there is a duty the two of them have to carry out: to review a tape Kirk left them. They go there and get the tape but McCoy wants to know why Spock stayed. Spock insists he was obliged to make sure of the captain's status. They then play the tape, where Kirk notes they're probably both feuding and suggests they cooperate. After the tape is done, McCoy apologizes and they head back to their posts.
Uhura is resting in her quarters when she feels a brief burst of pain then sees Kirk in her mirror. She runs into the hallway and meets McCoy, who suspects she is suffering from a bout of insanity and has her taken to sickbay. In Engineering, a crewman goes insane and is taken to sickbay, where McCoy is getting close to a cure. While Chekov is ranting in his bed, Uhura is calm and concerned she'll go insane like Chekov. In Engineering, Scotty spots a ghostly Kirk and Spock and McCoy wonder if it's some kind of shared hallucination. McCoy briefly snaps at Spock before recovering, then he collapses. Scotty arrives on the bridge and they all see Kirk manifest as a ghost for a minute before disappearing.
McCoy releases Uhura now that they've all seen Kirk, confirming she isn't insane. He then meets with Scotty and Spock, who have confirmed that the overlap time for interphase has changed, and they have 20 minutes. McCoy tells them he's come up with a cure, a derivative of Klingon nerve gas. Chekov has already recovered and Scotty takes some to mix with Scotch.
The Tholians are close to completing their web and they've programmed the ship to pass into interphase. As they prepare to transport, Kirk appears on the viewscreen and the tractor beam activates, pulling them out. The Enterprise disappears out of the web, appears briefly in a black void, then fades back into normal space. They've thrown themselves 2.7 parsecs distant but managed to maintain a transporter lock on Kirk. McCoy is ready in the transporter room as the captain's oxygen begins to run out. They see Kirk on the viewscreen again and the transporter room beam Kirk in just in time.
Later on the bridge, Kirk explains how he was alone in the universe and Spock and McCoy don't mention that they listened to Kirk's last words of advice, or had any problems. Kirk is a bit skeptical…