The slingshot effect is a method of time travel in which a starship flies around a star at high warp, using its gravity to propel the ship forward or backward in time.
The Enterprise first travelled through time this way by accident in 2267, when it was flung back to 1969 Earth and had to repeat the maneuver to return home. Starfleet later used the technique deliberately for historical research, and it was during such a mission that the Enterprise encountered Gary Seven in 1968.
In 2286 Kirk and his crew used the effect in a captured Klingon bird-of-prey, circling Earth's sun to reach 1986 and retrieve humpback whales needed to answer an alien probe.