Trelane was a member of the Q Continuum who the crew of the USS Enterprise encountered in 2267. Trelane harassed the crew of the Enterprise before he was found by his parents and taken home. At the time Trelane was fascinated with 18th century French culture.
Trelane later escaped from his parents again. The Enterprise again encountered Trelane in 2269 while investigating the disappearance of several vessels. During their second encounter, Trelane had become fascinated with the First World War. Trelane attacked the Enterprise with a space vessel made to resemble an early biplane. Kirk and the Enterprise crew were able to defeat the biplane, but Trelane then subjected several Starfleet officers to a simulation of a period German village. Kirk was again able to disrupt Trelane's power, and Trelane's nanny discovered him and took him away.
In the 24th century, the crew of the USS Enterprise-D encountered Trelane, and finally learned that he was a member of the Q Continuum. After Trelane acquired control of the Heart of the Storm- a part of the fundamental structure of the universe, capable of granting Trelane power over the very structure of chaos itself-, he began to collapse three alternate timelines together for little more than the sake of it, driving an alternate version of Jack Crusher insane by revealing that he was the only version of himself left in the multiverse, as well as dispersing Q across the universe after sealing the Q Continuum away from the rest of reality. However, Q was able to piece himself back together over the millennia thanks to a signal sent out by his future self, with the result that, when he 'caught up' with Trelane in the present, his powers were intact enough for him to protect Captain Jean-Luc Picard and some of his crew from the insanity that would have been caused by Trelane's manipulation of reality. With the aid of Commander Riker, Lieutenant Worf and an alternate version of Lieutenant Commander Natasha Yar, Picard was able to teleport down to the planet Terminus- an artificial creation made to serve as a focus for Trelane's game- and confront Trelane in a sword-fight using a sword that was really Q's essence, Picard exploiting Trelane's overconfidence and limited practical knowledge of swordfighting to stab him in the chest, allowing Q-in-the-sword to disrupt Trelane's connection to the Heart of the Storm and disperse him into nothing, simultaneously restoring Q's powers. As he restored reality to normal, Q implied in a conversation with Picard that Trelane may have been his own illegitimate son, but his mother's high status in the Continuum meant that any relationship between her and Q would have been scandalous at best, and Picard respected Q's desire to let the matter drop.
In early 2372, Trelane began playing a strange game of chess with Q, using the crews of two starships Enterprise as pawns. As each superbeing was convinced that the captain he was used to dealing with was superior (Kirk for Trelane and Picard for Q), they switched the captains' places, allowing Kirk to take command of the brand-new USS Enterprise-E on the day of its launch, while Picard had to assume command of the original Enterprise during a Klingon attack. Both captains adapted to their new situations, and were able to work together to overcome Trelane and Q.