Crossroad by Barbara Hambly
The crew of the Nautilus, a battered Starship of mysterious origin, is beamed aboard the Starship Enterprise. The group claims they are freedom fighters from the future working to save the Federation from the Consilium, a group of corrupt power-seekers.
The Nautilus crew members then seize control of the U.S.S. Enterprise, and a Starship from the future arrives to arrest the renegades. Kirk must separate his true allies from those who wish to destroy the Federation.