This sounds like a scrambled recollection of either Arthur C. Clarke's Against the Fall of Night (1953) or The City and the Stars (1956). The former is substantially shorter, so it's possible you remember it as less than novel length.
Selectively quoting the Wikipedia summary of Against:
Diaspar is the last human city, hundreds of millions of years old. Alvin, born seventeen years ago, is the first child to be born in 7,000 years and lives among ancient immortals with unchanging lives. The Earth he knows lies in ruin, a vast desert, after a cataclysmic war with the Invaders millions of years ago confined mankind to the planet. He is fascinated by the world and its history, which his tutor Jeserac finds disturbing, the fear of doing anything that might trigger a return of the Invaders remains palpable. Bored, Alvin explores the empty sections of the city, and on one such trip, finds stairs leading to the desert outside.
Three years later, Rorden tells Alvin that he has deciphered Alaine's message, and takes him to a park in the center of Diaspar. There lies a monument to Yarlan Zey, designer of the park, which Rorden realizes was built to conceal some sort of transport. Rorden triggers a hidden elevator that takes them to an underground train station. A large map on the floor shows Diaspar as a brightly lit dot among many dimmed destinations, but one other dot remains lit, "Lys".
The old man is the last remaining follower, sending signals into space to attract the Great Ones. He also controls the Master's machines, three advanced intelligent robots, but the Master instructed them to keep secrets. Alvin convinces the man to lend him one of the robots so he can take it to Rorden, promising to return it.
The boys return to Lys, and Alvin is given the choice of staying in Lys forever or returning to Diaspar without his memories. Alvin agrees to the mind wipe but programs the robot to grab him and take him to the transit station before this occurs. He returns home, and Rorden takes Alvin and the robot under the city to meet the Master Robots, the computers that run the city. They are unable to remove the instructions from the Master, so they instead make a duplicate robot without the instructions in place.
Alvin explains that the new robot had revealed that the Master had landed on Earth not at Lys, but at the Port of Diaspar. He retrieves the ship from beneath the sand and flies to Lys where he learns they have also blocked the train, and sows confusion by claiming he used it without problem.