Episode Star Trek: The Next Generation S4E08 · 2367

Future Imperfect

Future Imperfect
Image: TMDB

Riker wakes sixteen years later with no memory of the intervening time.

During an away mission to Alpha Onias III, Riker collapses after being overcome by gas. He wakes up apparently sixteen years later as captain of the Enterprise, with a young son named Jean-Luc, and is told that an infection erased his memory. Federation and Romulan negotiators, including Tomalak, are about to meet aboard the ship.
Riker notices details that do not fit, such as the computer behaving oddly and the face of his supposed late wife, and realises the future is fake. It first seems to be a Romulan plot to extract secrets, but that turns out to be a second illusion.
The real author is a lonely alien child named Barash, hidden on the planet by his mother, who created the illusions to have company. Riker takes the boy with him.