Captain Picard receives a hail from Captain Donald Varley of the USS Yamato, informing him that Varley's ship has begun to experience system failures during a risky trip into the Romulan Neutral Zone. Varley, an archaeology buff like Picard as well as an old friend of his, believes he has discovered the fabled planet of Iconia. The Iconians were credited with advanced technology and Varley fears that the Romulans may use that technology against the Federation. As Varley explains further, the transmission is lost and the Yamato explodes due to a warp core breach, with a loss of all on board.
With the logs from the Yamato now downloaded into the ship's computer, Picard seeks out Iconia, which does indeed lie within the Neutral Zone, to discover what destroyed the Yamato and to keep Iconia's technology from the Romulans. En route, La Forge analyzes the logs for any clue as to how the disaster occurred. When the Enterprise arrives at Iconia they detect a probe launched automatically from the surface. La Forge is informed, but has discovered that the Yamato also detected such a probe. He races to the bridge and urges Picard to destroy the probe, which Picard does. La Forge has discovered that the probe transmitted a program to the Yamato, and that program (which is incompatible with Federation computers) tried to rewrite the computer systems of the Yamato, causing a warp breach. A copy of the "virus" has now infected the Enterprise, having been carried with Varley's logs. Fortunately, only a small portion of the logs are infected, slowing the spread of the virus.
Detecting an energy source on the surface of Iconia (which was a victim of orbital attack from its enemies), Data, Picard and Worf beam down to the facility. They discover a teleportation "gate" which seems to allow instantaneous interstellar travel, and this gate is operated within a facility for launching orbital probes. When he tries to access the facility's computer, Data is infected by the virus (as he is an android) but is able to tell Picard how to destroy the base. Picard also has Worf vaporize his tricorder so that no knowledge of the Iconian technology can be captured by the Romulans.
With the Enterprise's systems down, Picard is trapped in the crumbling base. He is forced to use the Iconian gate to escape, but arrives on the Romulan warbird, which is also infected by the virus. It is in an unstoppable auto destruct mode due to computer error.
Data eventually "dies" when his systems shut down because of the virus. A short time later he reawakens. La Forge surmises that Data's main memory core could not be accessed by the infiltrating virus, as it is protected. La Forge then uses the same technique to clear the Enterprise's memory: the ship is shut down and rebooted from its protected main computer core.
The crew beams Picard back off the Romulan ship and the Enterprise crew informs the warbird's captain on how to fix their computer, and Riker orders Data to engage the warp engines in case the Romulans fail to fix their warp core in time. The episode ends with the Romulan ship apparently successful, as it powers its systems back up, and engages its engines.