Engines of Destiny is a novel that takes place primarily in an alternate timeline 2293. Scotty and Guinan are the major characters, but Admiral Kirk, a Borg Queen, an alternate Sarek, and the Enterprise-D crew also play significant roles. The story relies heavily on the plots of Star Trek: Generations, Star Trek: First Contact, and the TNG episode "Relics," though it has continuity problems with the "Relics" novelization.
The Machine Age
After the apparent death of James T. Kirk on the U.S.S. Enterprise NCC-1701-B, Montgomery Scott decides to leave Starfleet. A chance encounter with a mysterious woman named Guinan leads him to hitch a ride on the U.S.S. Jenolen -- which crashes into a Dyson Sphere, leaving only Scotty to survive suspended as a transporter pattern....
Seventy-five years later, he is revived aboard the Enterprise-D -- on which Guinan serves as bartender. But fate has not finished with either Scotty or Guinan. The engineer hatches an audacious plan to travel back in time and rescue Jim Kirk the moment before he would vanish into the nexus and bring him back to the twenty-fourth century without damaging the timeline.
Scotty's plan, however, does not go as expected. Though Kirk is rescued, the famed captain and the engineer, as well as Captain Picard, Guinan, and the crew of the Enterprise-D, are trapped in an altered past where there is no Federation, and no human race. Sarek of Vulcan leads a ragtag collection of species fighting a losing battle against the Borg, who have swarmed into the Alpha Quadrant and assimilated Earth.
Starfleet's finest miracle worker must find a way to restore the timeline before the galaxy is overrun....
A year after Kirk's apparent death in the Nexus, retired Captain Montgomery Scott decides to join the Norpin V colony thanks to a brief encounter with Guinan. As seen in "Relics," that journey would see him trapped in a transporter pattern buffer for 75 years until the Enterprise-D rescues him. After being given the shuttlecraft Goddard, he roams space, haunted by dreams of Kirk and Ensign Matt Franklin, who died in the buffer.
About six months after being rescued, Scott responds to a distress call from two Narisian siblings, Garamet and Wahlkon onboard a century-old Starfleet shuttlecraft. Their race's technology has been accellerated by an unknown race called the Wise Ones. They lead Scott back to the equally-ancient Klingon Bird of Prey in which the Narisian Proctors discovered the shuttlecraft. Scott repairs the ship and christens it Bounty 2, but decides not to tell Starfleet about his find. (Star Trek III: The Search for Spock)
Instead, he returns to the Enterprise-D to retrieve the logs of the original Bounty's trip to the twentieth century (Star Trek IV: The Voyage Home), planning to reproduce the incident to save his captain. Guinan becomes concerned about his intentions, prompting the Enterprise to pursue his shuttle. Scott has enough of a head start to rendezvous with the Bounty 2, so the Enterprise follows him as closely as possible.
Arriving more or less when he means to, Scott beams Kirk from the Enterprise-B just before he would be pulled into the Nexus. At that instant, the Enterprise-B disappears, replaced by a pair of Borg cubes. Similarly, when the Enterprise-D arrives a few days later, its crew finds themselves in a timeline overrun by Borg.