Set in the 24th century, the series follows the adventures of the crew of the Federation starship Enterprise-D. In this episode, as the crew of the starship Enterprise struggle to prevent a moon from falling out of orbit, their situation is further complicated by a visit from a powerful nemesis named "Q" (John de Lancie), who informs them that he has been stripped of all his powers and must live out a mortal life.
The Federation starship Enterprise arrives at planet Bre'el IV to prevent the looming disaster of the planet's asteroidal moon falling from its orbit and crashing into the highly populated planet; as the ship arrives, the planet is already experiencing damaging effects of the moon's gravitational field. As the crew is working, Q (John de Lancie) appears on the bridge naked. Q explains that he is being punished by the Continuum for spreading chaos throughout the universe and he has been stripped of all his powers, banished from the Q Continuum, and transported to the Enterprise as a human, asking asylum. Picard reluctantly helps Q, but instead of assigning him guest quarters, Picard treats Q like a human and throws him in the brig.
As the moon continues to descend to the planet, Picard urges Q to use his powers and move the moon back into its original orbit. Q still insists that he is powerless except for his IQ of 2005. The captain assigns Lt. Commander Data to watch Q and is ordered to assist the Engineering team. Q suggests that they "change the gravitational constant of the universe." Experiencing hunger for the first time, Q goes to the Ten-Forward lounge with Data, who suggests a chocolate sundae. After ordering ten sundaes, his hunger is quickly displaced upon encountering Guinan (Whoopi Goldberg), who takes advantage of Q's mortal form to stab him with a fork. Shortly thereafter, Q is set upon by a cloud of gaseous entities called the Calamarain, who, having previously been tormented by Q, are attempting to get revenge. After raising the shields to prevent the Calamarain from attacking Q, Picard determines that Q took refuge on the Enterprise to protect himself from alien species that hold grudges against him.
Q's idea of changing the gravitational constant of the universe, impossible with human technology, sparks an idea in Chief Engineer La Forge (LeVar Burton) to modify the gravitational constant in a small volume of space, which he tests; however, the test lowers the Enterprise's shields, allowing the Calamarain to attack Q again. Data attempts to save Q from their assault but is electrified in doing so, nearly frying his positronic brain. Realizing that his presence on the Enterprise is doing more harm than he expected, Q leaves the ship in a shuttlecraft. As the Calamarain close onto the shuttle, a second Q being (Corbin Bernsen) appears on the shuttle and informs Q that the Continuum is willing to give him a second chance and restore his powers. Q accepts and shrinks the Calamarain entities and teleports them into the palm of his hand, gloating over the restoration of his powers. The other Q reminds him that he should reflect upon the lessons he's learned, and he grudgingly turns the tiny aliens loose. Q returns to the Enterprise and celebrates. Nudged by Picard to leave, he departs, bestowing a parting gift on Data for showing him how to be human. After Q disappears, Data begins to laugh uncontrollably for a moment, to the surprise of the rest of the Enterprise crew. Upon learning that the Bre'el moon has returned to a safe orbit, Picard surmises that Q is responsible, and says that perhaps Q has a residue of humanity after all, but a cigar appears in Picard's hand with the usual dash cross-star white light, with Q's voice telling him, "don't bet on it."