The Enterprise is recalled to Sector 001 (Earth) on a priority mission, the crew only being told that evidence has been discovered which indicates the presence of extraterrestrials on Earth – 500 years earlier. Beaming down to Starfleet Headquarters in San Francisco, Captain Picard and Data are conducted to a cavern a mile beneath the surface, where they are shown a variety of recovered artifacts including a Colt Single Action Army revolver and an engraved pocket watch. Their guide explains that originally work crews were in the cavern to install seismic regulators, but something kept interfering with the equipment. The interference turned out to be due to Triolic waves being given off by the walls of the cavern, which was exposed to the radiation back in the 19th century. The Triolic emissions had to be of an alien origin, since such emanations would not exist on Earth in either the 19th or 24th century, due to their deleterious nature to humans. Picard observes that while all this is interesting, he still has to wonder why Starfleet chose to involve the Enterprise in the investigation. Explaining that there was one more artifact he hadn't shown them yet, their guide pulls back a cover to reveal Data's severed head lying on the floor of the cavern.
Aboard the Enterprise, Chief Engineer Geordi La Forge analyzes the information which has been gathered, and comes up with some facts about the aliens. For one thing, their resistance to Triolic radiation indicates they may be shape shifters, which would enable them to pass themselves off as humans while on Earth. He also finds a cellular fossil of type L-B-10445 which is native to the planet Devidia II in the Marrab sector. Picard orders Commander Riker to set course for Devidia.
Upon arrival at Devidia, Data locates a temporal disturbance and Triolic waves. Riker, Lt. Worf, Geordi, and Deanna Troi form an away team to investigate, but fearing for Data's safety, Picard does not let Data go.
Beaming down, the team finds themselves in a seemingly deserted cavern. Deanna senses life though, human life forces, and she can empathically feel that the humans are terrified. An analysis of the cavern's Triolic emanations indicates that the cavern is indeed inhabited, but that the occupants are out of phase with the normal time continuum by a fraction of a second, while the away team occupies the same physical space, they cannot see the aliens since they are in a different time. Data and Geordi realize that with a very sensitive phase discriminator a contained subspace force field could bridge the time gap. Data points out that he has such a phase discriminator built into his positronic decompiler. Reluctantly, Picard gives him permission to join the away team.
Once on the planet, Data explains to the away team that he has modified the communications system by linking it with the discriminator, so that the other members of the team will be able to hear him over the comm system once he activates the force field. As he adjusts the force field projector he brought with him, he vanishes. His voice continues to come over the communicators however, and he advises the rest of the team that he can now see the aliens and describes them as small, humanoid, silvery, and possessing an orifice on what would be the forehead. He adds that they do not seem to be aware of, or at least acknowledge, his presence. He states that they are surrounding some kind of apparatus which is emitting energy filaments which the aliens ingest through the orifice, perhaps some kind of nourishment. There apparently are hundreds, or perhaps thousands of the energy filaments in the top of the apparatus, it seems to be some type of storage device for them. He also notices an ophidian (snake) nearby which is restrained by a force field. Two of the aliens approach the ophidian and release the field, at which point a loud noise comes over the comm link. Data's voice suddenly becomes indistinct and distorted, he only has time to say something about a “temporal disturbance of mass proportions” and “the time space continuum”, and that he is “caught in the after effect”. Suddenly the rest of the team see a bright flash and the subspace field generator Data was using appears on top of a rock nearby. Riker sombrely reports to Picard that they have lost Data.
Data finds himself lying on a cobblestoned street. He sits up and looks around to find himself in 1893 San Francisco. He begins looking for the aliens and their snake, meeting up in the process with an old bum who offers him some tips on the fine art of panhandling. Having no funds, and realizing that he needs lodging, he approaches a friendly seeming hotel bell hop and inquires about employment. The man can't help him, but greets another passerby and inquires about his luck playing poker, and at Data's request tells him about the location of the game. Joining the game, Data quickly cleans out the other players, who he later finds out were card sharks. With his winnings he rents a room at the hotel. He tells the bell hop that he is an inventor, and asks him if he can procure some needed items. Outside, the old deadbeat whom Data had spoken with earlier is accosted by a man and woman dressed as doctor and nurse, when he asks them for help a beam comes from the doctor's satchel and leaves him slumped dead in the alley.
Aboard the Enterprise, although Riker and the rest of the crew are very emotional about Data's disappearance, Picard points out that they can't let recovering Data become their priority. Riker responds that since Data may now know more about the situation than they do, finding him may help more than anything else in the resolution of the situation. Picard observes that while he hopes this will be the case, it is vitally important that they determine the extent of the threat to Earth, and orders La Forge to attempt to produce an equivalent to Data's phase discriminator chip so that they can attempt to make contact with the aliens. Geordi says that while there is nothing even close to what Data has aboard ship, perhaps he can build one, and sets out to do so. Ten-Forward hostess Guinan contacts Picard and requests a meeting; she tells Picard that he must join the away team he's sending to the planet. He finds this strange and attempts to question her, but she refuses to tell him much more, other than enigmatically saying that the two of them will never meet if he doesn't go.
In San Francisco Data has constructed an apparatus with which he can monitor temporal distortions in an effort to track the aliens. Wondering what the device is, the hotel bell hop ventures that it is perhaps a new engine for horseless carriages. Telling him that it is, Data looks at the paper the bell hop brought and is amazed to see a picture of Guinan there, apparently she is appearing as a guest of a prominent nature as to a literary reception.
At the reception Guinan is speaking to another of the guests, Samuel L. Clemens (Mark Twain). Data arrives and attempts to speak to Guinan, but finds that she doesn't recognize him. Data then realizes that he has made an error: Guinan hasn't followed him back from the future as he assumed, but he has met an earlier temporal incarnation of her. (Guinan is a member of the extremely long-lived El-Aurian species). Data tells her that he is from the future and briefly describes the situation, while an eavesdropping Clemens overhears everything.
On Devidia II the away team (which now includes Captain Picard) uses the device Geordi built to phase shift into the alien's time continuum. Dr. Crusher quickly discovers that the filaments originally observed by Data are organic, possibly a life form. Troi corrects her that they are not alive, what she had mistakenly earlier thought was life was just an “echo” of the last moments of life.
All at once a bright doorway of light appears, and two aliens come through, bearing more of the filaments for the other aliens to ingest. After depositing the new filaments into the apparatus the creatures start to leave again, and as they do the Enterprise team follows them through the glowing gateway.
In the 19th century, the crew is reunited with Data. In a struggle with the time-traveling aliens, Data’s head is severed by the gateway—remaining in 19th century earth—as one of the aliens escapes back into the 24th century, along with the Enterprise crew members, and Samuel Clemens. Having brought the headless Data back with them, the crew decides to attach the 500-year-old head from the cavern.
Back in the past, Picard is tending to Guinan, who was injured during the struggle. In a conversation with the alien who remained behind, Picard learns that if the Enterprise tries to destroy the aliens’ base of operations in the 24th century, the aliens’ power will be amplified. With no other way to warn them, Picard uses an iron filing to insert a binary message into Data’s head. In the future, the crew successfully attaches the 500-year-old head, is made aware of the message, and avoids destroying the aliens’ base in a way that will be counterproductive. Commander Riker decides to use the aliens’ time-travelling device to retrieve Captain Picard from the 19th century but discovers that only one person will be able to return.
Upon learning this, Clemens states that he is the logical choice to travel back in time, stay there, and give the device to Picard so that he can return to the future. When Picard says that he wishes he had the time to get to know Clemens better, Clemens tells him to read his books, that who he was is in these books. Picard returns to the future, and the Enterprise destroys the aliens’ base of operations.
Back in the 19th century, Clemens is having the injured Guinan taken out of the cave. He decides to leave his watch behind in the cave. The show ends with a shot of Data’s severed head, lying on the floor of the cave.