The Shadow Out Of Time by H. P. Lovecraft

In this chilling tale, a professor named Nathaniel Wingate Peaslee experiences a mysterious five-year amnesia, during which his consciousness is replaced by that of a member of the Great Race of Yith, an ancient extraterrestrial species capable of time travel. As Peaslee gradually uncovers the truth about his lost years, he discovers the Yithians' vast library of knowledge and their ability to project their minds across time and space. The story delves into themes of identity, the fragility of human understanding, and the terrifying realization of humanity's insignificance in the cosmic order.