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 criminal 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." Q begins experiencing more human conditions, such as back spasms and hunger. Data takes Q to the Ten-Forward Lounge. When Q inquires about what food is best to address his constant suffering, Data suggests a chocolate sundae as he has observed many female crew members turning to chocolate when depressed. 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 due to his selfless act to protect the Enterprise, 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 Q how to be more 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 Q's voice telling him, "don't bet on it."