Imaginary Gary is the seventeenth episode of Season 3.
When Timmy wishes his imaginary friend Gary was real, Imaginary Gary is instantly favored by Timmy's friends, family, and even Trixie. It then turns out that Gary wants revenge for Timmy abandoning him when Timmy got real friends. Timmy can't even unwish him because Gary is from his imagination, and thus is a part of him, allowing Gary to make wishes too. Timmy must now stop Gary before the latter eliminates Timmy as an act of vengeance.
Mrs. Turner is busy cooking Yamsberry Pie when Timmy comes up to her wanting to play Surgeon General, a board game for ten year old kids. However, Timmy's mom and dad are simply more interested in sitting around watching the pie bake rather than play with Timmy. Disappointed, Timmy goes to his fairies and tells them about his old imaginary friend, Gary, that he used to go on fun adventures with all the time, saying that "He was cool!" and showing pictures of him and his non-existent friend on a teeter totter, about to beat up the monster in Timmy's closet, and at therapy "together". Timmy wishes that Gary was real, and Gary appears from a crude drawing Timmy drew of him, a real human being.
Gary points at Timmy accusingly at first, but quickly regains his composure and approaches Timmy as a friend. Timmy tries to hug Gary but he pushes him off saying that "Public displays of affection are Not. Cool." Cosmo and Wanda seem to like Gary, he knows who they are and greets them as "Cos and Wan". Timmy wants to play with kites and other boys stuff, but Gary says those things are "Also not cool." When Timmy asks "What is cool?", the scene changes to him suddenly asking his parents for the keys to their car. Mr. Turner tosses Timmy the keys, but Mrs. Turner snatches them out of the air saying that Timmy is not old enough to ask for the car or drive. Timmy says that he wants to go the arcade with Gary, causing his parents to worry for a second that Gary was back and Timmy needed to go to therapy, but they are surprised when the real Gary appears and charms them with his coolness. Timmy tries to be cool too, but ends up blowing up the oven and the pie inside.
At school, Chester is showing off a possum to A.J. and Sanjay, when they spot Gary and Timmy approaching them in stride. Gary grins wickedly and then trips Timmy who ends up with a mouth full of turf. Timmy's friends are impressed by Gary, but when Timmy tries to get them to play Surgeon General with him, Gary remarks that board games are uncool, and runs off with Timmy's friends to go do something cool. Timmy talks it over with Wanda, when he wonders where Cosmo is. Even Cosmo is following Gary around like Timmy's friends, disguised as a dog. At lunch, Trixie approaches Timmy, who becomes enthralled that she is actually speaking to him, but it turns out she just wanted to get to know who his "new cool friend" was. Gary was busy cracking jokes about Timmy at lunch, and every time he snapped his fingers a bunch of students would faint from his coolness. This is the last straw, Timmy demands to talk to Gary outside.
When Timmy confronts Gary outside, asking why Gary was trying to win over Timmy's friends and "not-girlfriend", and why he was making Timmy seem uncool in front of everyone. Gary is starting to reveal a resentment toward Timmy, so before anything can get out of hand Timmy wishes they were back at home. However, Gary wishes they weren't back at home and Cosmo and Wanda oblige. It turns out that since Gary is part of Timmy's imagination, he is part of his mind and thus he controls Timmy's fairies too. Timmy tries to get rid of Gary by wishing he was back in his mind, but Gary wishes that Timmy was in there with him and they are both sucked into Timmy's imagination.
Inside Timmy's mind, Gary reveals his resentment toward Timmy. When Timmy did not need an imaginary friend anymore, he locked Gary away inside his mind. Gary welcomes Timmy to the very prison that Timmy locked him away in, and uses figments of Timmy's imagination to trap him. Gary stuffs teletubbies into Cosmo and Wanda's ears so that they can't hear Timmy's wishes, and then locks Timmy into a large building block prison and begins to pile Timmy's five year old's toys on top of him. However, Timmy realizes that he is ten and he can use his ten year old stuff to beat Gary. He attacks Gary with a giant Surgeon General robot. Gary counters with the monster from Timmy's closet, but Timmy realizes that at age six he realized it was not a monster in the closet, but a green sweater (which the monster turns into), and at age eight he met a real monster, Vicky, a giant version of her then appears from the green sweater and attacks Gary. He is swallowed by the giant Vicky but vows to escape in the name of everything that is cool. Timmy wishes himself out of his mind before the giant Vicky can get him too. They escape out of a door labeled "exit", but Cosmo forgot to lock it. Eventually the giant Vicky threw up Gary because she hated the taste of cool, and Gary opens the exit door to Timmy's mind and begins to laugh for a moment before correcting himself, saying that laughing maniacally is not cool.