Riker is put in charge of an undercover mission to Tilonus IV, a planet that has descended into anarchy. Since the trip there will take a few days, Riker is able to retain his starring role in the ship's play while he prepares for the dangerous mission. However, he soon begins experiencing an unusual sensation that people, especially a strange alien lieutenant, are staring at him. Troi tells him this can be attributed to his getting into his character — that of a mental patient trapped in an asylum. However, when he performs the play, Riker is shocked when the set suddenly becomes an actual asylum cell. The audience disappears, leaving Riker in a real mental ward with a real alien doctor.
The therapist, Dr. Syrus, tells Riker that the play is a delusion, and that he is in a Tilonus mental hospital. Later, an attendant named Mavek escorts Riker to the Common Area, where he sees a doctor who looks just like the alien who was haunting him on the U.S.S. Enterprise. Mavek tells Riker he was brought to the hospital because he committed murder. A panicked Riker tries to attack Mavek, but is subdued and injected with an alien syringe. Riker suddenly sits bolt upright in bed on the Enterprise, relieved that it was all a dream.
Riker and Beverly attribute the dream to nervousness about the play, which is set for that evening. During the performance, Riker is distracted by flashes of his nightmare, and shocks the audience when he angrily confronts Lieutenant Suna, the alien he saw in his nightmare and aboard the Enterprise. Beverly takes Riker to Sickbay and examines him, but can find nothing wrong. Riker then tries to walk back to his quarters, but hallucinates that he's walking in the asylum. When he finally reaches his quarters and closes the door, it locks, and he is in the cell again.
Convinced that he is losing his mind, Riker tells Dr. Syrus that he is ready to cooperate. The doctor subjects Riker to Reflection Therapy, observing Riker use images of Picard, Troi, and Worf to represent different parts of his own psyche. He then sees an image of the alien lieutenant, who according to Dr. Syrus is actually the hospital administrator. The images of the Enterprise officers try to convince Riker that he is still on the starship, but Riker dismisses them, telling them they are not real. Later, Beverly joins Riker in the Common Area, tells him this is all a part of his mission on Tilonus IV, and that the crew is attempting to get him out. Riker, however, refuses to acknowledge her. Then, that night, Data and Worf break into Riker's cell in an effort to free him, but Riker breaks away and runs to the guards, refusing to trust that the Enterprise officers are anything more than delusions.
Worf and Data are able to defeat the guards and transport Riker back to the Enterprise against his will. But while Picard informs Riker that he was abducted during his undercover mission, Riker reacts to a minor head wound Beverly can't seem to stop from bleeding. Struggling to regain his grip on reality, he volleys between delusions of the ship, the play and the alien asylum, until he finally wakes up in a lab, with a probe connected to his head and the alien doctors surrounding him — the leader being the mysterious alien he had been encountering over and over again. Seeing that he is dressed in the undercover costume he was given for his mission to Tilonus IV, he realizes that this Is reality and hurriedly locates his communicator. Before the aliens can stop him, Riker calls for an emergency transport and is beamed safely back to the Enterprise, where he learns the truth: he was abducted during his mission and used his last memory of the Enterprise — the play — to defend himself against experiments the aliens performed on his brain.