Mr. Atoz was an inhabitant of the planet Sarpeidon whose sun was going supernova. He was the overseer of a library and the atavachron, a time portal device that he used to transport the inhabitants of the planet into the past in order to escape its destruction. He had created replicas of himself to help him in the library.
When Kirk, Spock, and McCoy arrived on the planet to investigate its star going supernova, Atoz believed that they were citizens of his world and chided them for being late for transport. After Kirk escaped the past of the planet, he forced Atoz to help him locate Spock and McCoy.
Atoz, at first, resisted and attempted to send Kirk back to the past. When the missing men were located and returned to the present, Atoz went through one of the portals into his planet's past to join his wife and family and escape the supernova. Kirk noted that Atoz had his escape planned well in advance, and despite the conflict between them, said that he was glad the dutiful librarian made it to safety. (TOS: "All Our Yesterdays")