Alastor “Mad-Eye” Moody managed to alter the Triwizard Tournament in Harry Potter and the Goblet of Fire by adding the titular figure as a competitor, but it took a well-orchestrated plan. Brendan Gleeson made his franchise debut in the fourth installment of the film series based on the novel series by author J.K. Rowling. Although Mad-Eye served as a key member for the remainder of the Harry Potter franchise, he wasn’t exactly himself in his introductory appearance. In fact, another figure was impersonating him all along.

Mad-Eye was a legendary Auror and a member of the original Order of the Phoenix before accepting a teaching position at Hogwarts prior to the events of Goblet of Fire. Albus Dumbledore hired the wizard as the new Defense Against the Dark Arts professor, seeing as he was skilled in battling the specific method of magic. During his first year as the DADA professor, Mad-Eye demonstrated the three Unforgivable Curses in front of his students. He also guided Harry Potter during the Triwizard Tournament, but he ended up having ulterior motives.

Related: Harry Potter: Why Dumbledore Is So Angry In The Goblet Of Fire Movie

Lord Voldemort needed a pathway to Harry to complete a ritual that would bring back the Dark wizard’s physical body, and that opportunity hinged on the student’s participation in the Triwizard Tournament. To infiltrate Hogwarts in order to manipulate Harry, Voldemort enlisted the help of a Death Eater named Barty Crouch Jr., who previously escaped from Azkaban. Barty then kidnapped Mad-Eye and disguised himself as the professor by using Polyjuice Potion. This allowed Barty to walk freely around Hogwarts as he concocted a precise plan to give Harry a chance to participate in the Triwizard Tournament. In order to do so, the Death Eater was forced to use magic to carry out the next step of the plan.

The Triwizard Tournament traditionally featured one student from each of the three schools in attendance. That trio of Champions wasn’t allowed to be under the age of 17 based on the age spell that Dumbledore put in place. Despite those restrictions, Harry’s name was chosen as the fourth Champion from the Goblet of Fire, the impartial judge used to select contestants. While staff and fellow students believed that Harry may have put his own name in the Goblet of Fire, it was actually Barty disguised as Professor Moody. Barty used a powerful Confundus Charm to confuse the Goblet of Fire so that it would select Harry’s name as the fourth contestant from an unspecified school.

The plan worked since Harry followed through the competition against Cedric Diggory, Fleur Delacour, and Viktor Krum. Barty, meanwhile, continued guiding Harry through the three tasks before successfully turning the Triwizard Cup into a Portkey. Voldemort was able to restore his physical body before Barty intended to kill Harry to solidify himself as one of the Dark Lord’s most loyal followers. Instead, Dumbledore and other members of the staff caught on to Barty’s ploy and rescued the real Mad-Eye, allowing for his presence in the succeeding Harry Potter installments. Rather than serve a long-term punishment, Barty was killed by a Dementor’s Kiss.

Next: Harry Potter: Hermione’s Parents Almost Had A Connection To Baby Harry