The Guardian of Forever was a construct of an unknown, ancient alien race that functioned as a time portal, a gateway to the time vortex that allowed access to other times and dimensions. It was located on an ancient planet where the focus of all timelines throughout at least the Milky Way Galaxy converged. It was apparently sentient, responding to external stimulus such as questions and actions, and could even somehow control the flow of time. It generated immense ripples in time that manifested themselves as spatial disturbances in the region around the planet where it was located.
The Guardian was located among the ruins of a large, forgotten city that stretched beyond the horizon in all directions around it. Based on initial observations, the ruins appeared to be at least one million years old.
Capable of speaking to those around it, the Guardian explained that it was "its own beginning and its own ending," and that, "since before your sun (Sol) burned hot in space, [it had] awaited a question." Apparently an inert formation of quasi-metallic substance, the Guardian created portals to other times.
The Guardian was first discovered by the crew of the USS Enterprise in 2267. Encountering powerful waves of space displacement, which Spock described as "ripples in time," the Enterprise tracked the waves back to their point of origin on a previously-uncharted planet. Doctor McCoy, suffering from paranoid delusions as a result of an accidental overdose of cordrazine, beamed down to the surface in an attempt to escape the ship. Searching for McCoy, Captain Kirk and Spock encountered and made contact with the Guardian, who offered them the chance to explore the past. As the Guardian was displaying images from Earth history, McCoy emerged from hiding and leapt through the time portal, arriving on Earth in the year 1930. The landing party soon discovered that they had lost all contact with the Enterprise, and the Guardian informed them that McCoy had effected a change in history, wiping out their civilization. Realizing that they must correct the damage to history, Kirk and Spock had the Guardian replay Earth history, and traveled through the portal to a point in time prior to McCoy's arrival. Eventually successful in their effort to restore the timeline, the Guardian returned all three of them to their proper place and time, mere moments after they initially departed.
In 2269, a team of historians, accompanied by Captain Kirk and Spock, used the Guardian to investigate Federation history. Their investigation included firsthand accounts of the formation of the Orion civilization and the monitoring of Vulcan history of the 2230s and 2240s. While Kirk and Spock were visiting Orion, their support team was monitoring Vulcan's past, which, in doing so, inadvertently removed Spock from the proper timeline. Spock, however, was protected from the change while he was in Orion's past, and the change to the timeline went unnoticed until he and Kirk returned through the Guardian. Once the cause was determined, Spock was able to use the Guardian to return to his own childhood on Vulcan, and prevent his death during the kahs-wan ritual.