Commander Riker is preparing for a covert mission. Worf briefs him on what he needs to do and accidentally cuts Riker on the side of his head. Riker goes to sick bay and Dr. Crusher heals it, but it still hurts.
Riker rehearses for a theater play which is called "Frame of Mind", due to be performed before the mission. His part is that of a man imprisoned in an Orwellian mental hospital who has been repeatedly exposed to hallucinogenic drugs in an attempt to convince him that he is a murderer.
During his rehearsals, Riker suffers from nervousness and paranoia; he catches an alien lieutenant staring at him several times, although nobody else seems to notice him.
After several rehearsals, it's finally the day of the performance. Riker delivers a spectacular performance. He grows increasingly agitated while talking to his doctor (Data); he's recovering from his latest dose of drugs and is becoming angry as he realizes his predicament. Riker's character delivers a soliloquy on sanity, seemingly convincing himself that he is indeed sane. Data shakes his head and says "I see we still have much work to do" and leaves the room. Riker dashes to the cell door and claws at it maniacally, but then sinks to the floor sobbing. The play is over and he gets up to bow with Data. He looks up into the audience and sees the lieutenant in the middle, frowning. Riker shudders but takes a deep bow. When he straightens, he's facing a gray cell wall. He glances around only to discover he's in the cell from the play. The doctor (not Data this time) on his right raises his eyebrow and says "I see we still have much work to do."
Riker is taken to the asylum cafeteria. There, a guard reminds him that he killed a man. Riker, remembering the drug torture done to him in an attempt to convince him of that very fact, becomes furious and tries to strangle the guard. The guard injects him with drugs, and he collapses. He wakes up on stage in the Enterprise. Riker at first tries to deliver his lines, but then notices the lieutenant in the audience and accosts him, shouting "Who are you?!?". Crusher takes him away to sick bay. After conversations with several of the crew (including Crusher, who wants to know how the play went in his dream, and Data who congratulates him on his convincing performance), he notices the lieutenant that had been staring at him. He instantly becomes terrified, sprinting into his quarters after seeing one of the insane prisoners in the hallway. He finds his quarters to be his cell and screams.
He is told by his doctor the next day that he must undergo treatment to try to ease his hallucinations about the Enterprise. He agrees, and they begin the procedure. A machine scans Riker's brain and projects Troi, Worf, Picard, and the lieutenant as holograms representing different aspects of his mind. Riker interacts with them and they tell him that he was attacked by his captors and he did nothing wrong. Riker rejects them to gain the confidence of his doctor and they disappear. The next day, Crusher visits Riker in the cafeteria, claiming that the Enterprise was working to get him out and she got in by posing as a health official. He refuses to listen to her and she leaves.
That night, Worf and Data appear in Riker's ward to rescue him. Riker yells for help, but Data and Worf are able to overwhelm the guards. They transport back to the Enterprise, and are greeted by the bridge crew. Riker realizes that something is wrong, however, when he notices his cut on his head is bigger than ever, and bleeding. Crusher silences his questions and heals him, but it instantly begins to ooze even more blood than before. Riker attacks Worf and takes his phaser but he's not willing to take the chance that he's not crazy himself, so instead of shooting Crusher, he shoots himself.
The scene shatters, and he finds himself in his cell with the hospital administrator and two guards. To his confusion, he still has the phaser in his hand. The administrator claims it is a knife, and Riker proves him wrong by firing at one of the guards and shattering him. He then sets the phaser to destroy half of the building and fires it, and the scene shatters to reveal the audience from the play. As he confronts the administrator and refuses the cooperate with him, the audience applauds and cheers him on. When he turns around and pounds his fists into the back wall while shouting "THIS ISN'T REAL!", the entire scene shatters spectacularly and Riker, finding himself on an operating table, realizes that he is finally in reality. He knocks one of the alien doctors unconscious, threatens the other with a knife, and calls for an emergency beam-up. He returns safely to the Enterprise and learns what really happened.
During the away mission, Riker was captured by the planet's inhabitants. He was then taken as a prisoner to a laboratory where his captors began brain probing scans in order to access his knowledge of strategic information regarding the Federation. The entire duration of the episode was Riker's attempt to subconsciously use his memory of the Enterprise and the play to defend himself from the aliens' scans.
The episode ends with Riker alone in Ten Forward, strike the set of Frame of Mind.