As the episode opens, Lieutenant Reginald Barclay, a Diagnostic Engineer who recently transferred to the Enterprise, is sitting at the bar in Ten-Forward. Hostess Guinan tells him that she doesn't want any trouble, adding that where he goes, trouble follows. The ship's Chief Engineer Lt Commander Geordi La Forge enters, bossily reminding Barclay that he is on duty and needs to go back to work. Loudly telling La Forge to "take your holier-than-thou attitude and get out of my life", Barclay shoves him to the floor. Responding to Barclay's insubordination, the First officer of the Enterprise, Commander William Riker rises from his place further down the bar and challenges Barclay, but ends up also being beaten up and told by Barclay that he's nothing but "a pretty mannequin in a fancy uniform", adding that "If (Captain) Picard has a problem he needs to come to me himself." Enterprise Counselor Deanna Troi is sitting nearby and tells Barclay that his arrogant self-confidence "excites her". As the two are about to kiss, they are suddenly interrupted by a call over the ship's intercom, summoning Barclay to Cargo bay five "at once". In a much higher and squeaky voice an apologetic Barclay quickly acknowledges the call and leaves, revealing that everything which has just happened is merely a simulation running on the ship's Holodeck.
The Enterprise in the process of picking up Mikulak biological tissue samples intended for use in combating an epidemic of Correllium fever on Nahmi IV. In the Cargo bay, La Forge and Riker are overseeing the handling of some of the tissue sample containers just beamed aboard while also discussing Barclay, who apparently has not been performing his duties very well. La Forge tells Riker that he's just about had it with Barclay, who is always late, never gives his best effort, makes his crewmates uneasy, and always just barely squeaks by. He wonders to Riker how someone with these qualities could have made it through Starfleet Academy. Riker observes that perhaps it's time to speak with the Captain about "Broccoli", which he tells Geordi is a nickname acting Ensign Wesley Crusher came up with for Barclay, adding that Geordi needs to keep this to himself. La Forge smilingly tells Riker that the name fits. The Engineer handling the biological samples interrupts to inform the two officers that one of the containers is leaking, and Geordi tells him to destroy it lest it contaminate the others. At this point Barclay enters the bay, and seeing his superiors guiltily tries to duck behind some cargo containers, but Geordi sees him and calls him out, asking him if reporting to duty on time is a problem. Barclay attempts to invent an excuse but La Forge testily tells him to take a look at the balky anti-gravity unit the biological containers are being loaded on. Riker seizes Barclay's arm as he passes and tells him he is tired of seeing his name on report, adding that while he may have had too much laitude on his last posting, on the Enterprise he will be held to a higher standard.
Barclay works on the anti-grav unit for a few minutes, but in mid-travel it tips over, causing another canister to fall off and rupture.
In his ready room, Captain Jean-Luc Picard discusses âthe Barclay situation' with La Forge and Riker. Examining Barclay's service record, the Captain notes that he's not used to seeing a member of the Enterprise crew not performing up to par. Riker wonders if Barclay is "Enterprise material", and Picard observes that La Forge requested that Barclay be transferred. Picard questions why someone who has served Starfleet apparently competently for years is having such issues, adding that Captain Gleason of the Zukhov gave Barclay a glowing recommendation when he was transferring to the Enterprise. Riker conjectures that Gleason's recommendation served to offload a problem crewmember, adding that Barclay's psychological profile indicates a history of seclusive tendencies. La Forge tells his superiors that he thought he could work with anyone before Barclay came aboard, also pointing out that the awkward interactions Barclay has with his coworkers in Engineering make them nervous, and the nickname "broccoli" "stuck". Telling La Forge that the usage of the nickname needs to "get unstuck", Picard proposes that Geordi make Barclay his personal project, suggesting that La Forge try to make Barclay his best friend. Geordi objects but Picard insists, saying that it is too easy to simply pass the buck with a transfer.
Attempting to follow Picard's directive, La Forge checks Barclay's progress on the anti-grav unit. He takes a friendlier approach, praising Barclay's work and capabilities, even inviting him to the senior staff meeting at 0800 the next morning. Barclay arrives last, but promptly enough not to cause interruption, and with La Forge's encouragement delivers his status report concerning the difficulties with the anti-grav unit. However Barclay is secretly offended when Wesley points out something he overlooked.
Soon Barclay takes solace in the Holodeck again, discussing the meeting with a simulation of Troi, and states that he should have told Wesley off. Getting bored, Barclay changes the venue of the simulation to a heavenly jungle paradise, as well as altering Troi's clothing to a brief toga. In her new incarnation she identifies herself as "the goddess of empathy".
Geordi's team gathers in Ten-Forward to relax and the subject of the nickname surfaces again. La Forge cuts off the discussion, as the Captain had instructed. Duffy, another member of Geordi's engineering staff, finds that his drinking glass leaks and is oddly deformed.
Lt. Commander Data, the android Chief Operations Officer of the Enterprise, examines the glass and finds that its molecular structure is altered, which could indicate a problem with one of the ship's 4,000 power systems. La Forge assigns Barclay to look into the matter which Reg says he intended to do anyway as part of the anti-grav malfunction investigation.
Continuing the investigation on the Enterprise bridge, Data points out that it was Barclay who first suggested a connection between the Cargo bay problems and the drinking glass. Following his own advice to Geordi, Picard tries to involve the clearly uncomfortable Reginald in the discussion, but ends up unwittingly calling him "Broccoli" to his face. The Captain quickly corrects himself but is mortified at his slip.
In Ten-Forward La Forge discusses Barclay with Guinan; she describes Barclay as "imaginative", adding that Reginald reminds her of a black sheep relative whom she admired. She also points out that Barclay's actions aren't all that unusual considering that he knows everyone feels uncomfortable when he's around.
Desiring to check up on Barclay's progress, La Forge is irked to discover him on the Holodeck again. He finds himself in one of Barclay's "imaginative" holodeck programs, this one involving simulations of all the members of the senior staff including La Forge himself. Barclay's latest flight of fancy involves characters and situations evocative of "The Three Musketeers" with swordplay and period French costumes. As Geordi watches, Barclay takes on the holo-La Forge, Data, and Picard, easily defeating all three of them. A decidedly un-amused La Forge makes his presence known, much to Barclay's embarrassment.
After returning with Geordi to Ten-Forward, Barclay offers to be voluntarily reassigned, but Geordi, still mindful of his charge from the Captain, refuses to take him up on the offer. He tells Barclay that he has gotten a little mixed up a few times on the Holodeck himself, once even falling in love in there (Star Trek TNG:"Booby Trap"). Barclay admits that his habit began innocently when he "needed to blow off some steam" but got out of control. Geordi replies that personally he feels that what Barclay does on the Holodeck is his own business, but adds that it's unusual to simulate living people or one's crewmates. Worrying that Barclay's problem might be serious, La Forge orders him to talk to Counselor Troi about it. As he is infatuated with Troi, the prospect of meeting her in real life terrifies him.
La Forge is called to Transporter room three by Chief O'Brien, where the Chief demonstrates that it has begun to malfunction, objects repeatedly beamed from one pad to another end up melted and smoking. Picard becomes concerned since they will need all the transporters working upon their arrival at Nahmi IV in a few hours, and orders a Level-one diagnostic to be performed. Riker starts to contact Barclay to involve him in this latest development, but Geordi asks Will to hold off until 1400 hours as he already has given Barclay an assignment.
Barclay attends the counselling session but feels very uncomfortable. After trying a breathing technique, he professes to be healed and quickly leaves Troi's office. Troi contacts La Forge and informs him that her "very strange" counseling session with Barclay did not go well. Riker comes in, and noting that Barclay has once again failed to appear for an appointment as ordered, decides to go to the Holodeck and confront him.
As La Forge, Riker and Troi enter the Holodeck, La Forge tries to warn them that Barclay has been running "some unique programs". This doesn't prepare a Riker who "has run out of patience with Barclay" for the shock of seeing the Musketeer program, including an asinine, stunted, and ungainly "Number One". Trying to disarm the situation, Troi observes that a healthy fantasy life can be a good thing, until she sees her own Holo-self in the form of the "goddess of empathy".
The Bridge calls the trio on the intercom, informing them the Enterprise has unexpectedly accelerated on its own to warp 7.25, so they quickly leave with Barclay to Engineering. Once there Barclay recommends dropping the ship out of warp, but the matter/anti-matter injectors jam and refuse to respond. The ship continues to accelerate and exceeds warp 9, Data estimating that the structural integrity fields will fail in 16 minutes, resulting in the ship's destruction.
With disaster imminent the engineering team brainstorm possible causes and solutions. After several theories are proposed and discarded, Barclay postulates that the events are connected by a human element, as he notices that the failures have all occurred when a member of the team was present. Geordi narrows 15,525 possible agents of contamination exist to two, Saltzgadum and Invidium. Wesley verifies that Invidium was once used by the Federation in medical containment, but is still in use on non-federation worlds such as Mikulak.
La Forge and Barclay quickly head to the Cargo bay where they verify the presence of Invidium in the sample containers. Barclay observes that if the temperature of the Invidium can be lowered below -200 Celsius it will be rendered inert, so Geordi orders the stuck injectors flooded with gaseous Cryonetrium at cryogenic temperatures, which brings them back online. Geordi recommends heading for Starbase 121 so their heavily Invidium contaminated ship can be cleaned up. La Forge tells Barclay that he is glad Reg was out with them in the real world on this day, as he was a key contributing element in the saving of the ship.
In the emergency's aftermath, Reginald Barclay enters the Bridge and somberly addresses the officers there, telling them that he has decided it will be best if he leaves the crew. Geordi speaks up tells Reg that he will always be welcome on the Enterprise, Picard adds it was a pleasure serving with him, Troi tells him that she wishes him good luck. Barclay tells them that it has been fun and then says "End program", making it apparent that this has been just another one of his fantasy scenarios. He walks away from his old life, in quest of a new one in the real world instead of his former Holodeck-fantasy-addicted reclusive attempt to escape from reality. He orders the computer to delete all of his saved programs, but at the last second saves "program nine". This done, he leaves the Holodeck for what will hopefully be a better and brighter future.