Captain Jean Luc Picard awakens from a nightmare in which he relived his assimilation by the cybernetic Borg six years earlier. Starfleet informs him of a new Borg attack against Earth, but orders the USS Enterprise-E to patrol the Romulan Neutral Zone so as to not introduce an "unstable element" to the fight. Learning that the fleet is losing the battle, the Enterprise crew disobeys orders and heads for Earth, where a single, damaged Borg Cube opposes a group of Starfleet vessels. The Enterprise arrives in time to save the crew of the USS Defiant which is being commanded by Lieutenant Commander Worf. After Picard hears Borg communications in his mind, he orders the fleet to concentrate its firepower on a seemingly unimportant section of the Borg ship. The Cube is destroyed after launching a smaller sphere ship towards the planet.
The Enterprise pursues the sphere into a temporal vortex. As the sphere disappears, the Enterprise discovers that Earth is now populated entirely by Borg. Realizing that the Borg have used time travel to change the past, the ship follows the sphere through the vortex. The Enterprise arrives hundreds of years in the past, to April 4, 2063, the day before humanity's first encounter with alien life after Zefram Cochrane's historic warp drive flight; the crew realizes that the Borg are trying to prevent first contact. After destroying the Borg sphere, an away team transport drive to the Montana site where Cochrane is building his ship, the Phoenix. Picard sends Cochrane's assistant Lily Sloane to the Enterprise for medical attention, then returns to the ship and leaves Commander William Riker on Earth to make sure the Phoenix's flight proceeds as planned.The Enterprise crew sees Cochrane as a legend, but the real man is reluctant to assume his historical role.
Borg survivors invade the Enterprise, and begin to assimilate its crew and modify the ship. Picard and a team attempt to reach engineering to disable the Borg with its corrosive coolant, but the android Data is captured. A frightened Sloane seizes the captain but he gains her trust, and they escape the Borg-infested area of the ship by creating a diversion in the holodeck.Picard, Worf, and the ship's navigator, Lieutenant Hawk, stop the Borg from calling reinforcements with the deflector dish, but Hawk is assimilated. As the Borg continue to assimilate, Worf suggests destroying the ship, but Picard angrily calls him a coward and vows to continue the fight. Sloane confronts the captain and makes him realize he is acting irrationally due to his desire for revenge. Apologizing to Worf, Picard activates the ship's self destruct. While the crew heads to escape pods, the captain stays behind to rescue Data.
As Cochrane, Riker, and engineer Geordi La Forge prepare to activate the warp drive on the Phoenix, Picard discovers that the Borg Queen has grafted human skin onto Data, giving him an array of new sensations. She has presented this modification as a gift to the android, hoping to obtain his encryption codes to the Enterprise computer. Although Picard offers himself in Data's place, the android refuses to leave. He deactivates the self-destruct and fires torpedoes at the Phoenix, but they miss and the Queen realizes Data betrayed her. The android ruptures a coolant tank, and the corrosive gas dissolves the Borg's biological components. Cochrane completes his warp flight, and the next day the crew watches as Vulcans, attracted by the Phoenix warp test, land on Earth and greet Cochrane. Having repaired history, the Enterprise crew returns to the 24th century.