Before Cobra Kai, actor William Zabka played a meta version of himself on How I Met Your Mother — here's a breakdown of every episode he made an appearance. Created by Craig Thomas and Carter Bays, the popular sitcom ran for nine seasons on CBS between 2005 and 2014. Starring Josh Radnor, it chartered the winding journey of Ted Mosby as he navigated love and life en route to meeting the mother of his future children. How I Met Your Mother also starred Alyson Hannigan, Jason Segel, Cobie Smulders, and Neil Patrick Harris.

Harris's Barney Stinson was widely considered the show's standout character. Barney was infamous for his womanizing ways and elaborate schemes. He equally harbored an extremely unique view of movies. In How I Met Your Mother season 4, episode 15, "The Stinsons", it was established that Barney was predisposed to root for characters traditionally viewed as villains. These include Die Hard's Hans Gruber and even the Terminator. Primarily, however, this quirk most passionately manifested with Barney's support for The Karate Kid's Johnny Lawrence (Zabka). As far as Barney was concerned, Johnny was the true hero and his loss to Daniel LaRusso (Ralph Macchio) in the film's conclusion declared a haunting tragedy.

Related: Cobra Kai Proves Barney's How I Met Your Mother Karate Kid Rant Was Right

With the release of Cobra Kai, and it's second life on Netflix, many have come somewhat around to Barney's way of thinking. At the very least, it has cast the characters with more shades of gray and blurred the distinction between heroes and villains. Whatever side of the fence individual fans land on, however, How I Met Your Mother took the gag to new levels later in its run. Zabka eventually emerged as a comical version of himself. Embracing his role as Barney's childhood hero, Zabka fed off the positive attention and reciprocated Barney's devotion with, occasionally, equal fervor. As such, the actor made frequent guest appearances across the final two seasons. Here's a break down of each one of them.

Season 8, Episode 22, "The Bro Mitzvah"

William Zabka as Himself Neil Patrick Harris as Barney Stinson How I Met Your Mother

When secretly organizing Barney's bachelor party, Robin sought to give her fiance everything he wanted...but without him being aware of it. A huge part of that was inviting Macchio to the event, knowing Barney didn't really consider him the Karate Kid. When the truth of the ruse came to light, Barney was delighted by Robin's deviousness and loved her all the more. However, he lamented that his real childhood hero hadn't made the appearance he'd always wanted. It was then that the party clown, who'd be hired to follow them around all night, removed his costume and make-up. Underneath it was revealed to be Zabka himself, thus completing one of the best nights of Barney's life. Wearing his full Cobra Kai gi, he celebrated Barney for being "one of the few people in the world who truly gets The Karate Kid movie". An overjoyed Barney immediately screamed his name and pulled him into a hug.

Season 9, Episode 4, "The Broken Code"

William Zabka as Himself How I Met Your Mother Season 9 Episode 4

After discovering that Ted still had feelings for Robin and "had broken the bro code", Barney angrily removed him as the best man for his wedding. Ted learned this only after a set of humiliating tasks and when he discovered the pre-wedding poker game was taking place without him. When he asked what was going on, Barney answered that the Best Man (and "the best around") had moved the time up. It was at that moment that Zabka turned and revealed that he was the one who'd stolen the slot. The decision was later reversed when Ted and Barney overcame the tension and reconciled. Zabka immediately vowed revenge, bitterly stating, "I'm coming for you, Mosby!"

Season 9, Episode 5, "The Poker Game"

William Zabka as Himself How I Met Your Mother Season 9 Episode 5

Picking up with the last episode left off, the poker game continued with Zabka still present. With Marshall absent and forced to join in via a video call, Zabka placed his bets for him. The actor is also a witness when Robin wins the wedding ring of Barney's brother, James, and later the blouse of Barney's mother, Loretta. When Barney and Robin started arguing about it, Zabka seemingly left the room with Lily and Ranjit. It was soon revealed, however, that all three had merely hidden somewhere in the room to eavesdrop. Zabka emerged last from within the cushions of the sofa. He then left for real to help Lily confront an old friend that had taken credit for Ted's wedding gift.

Related: How I Met Your Mother: Every Fake Website Created (That You Can Visit)

Season 9, Episode 10, "Mom And Dad"

William Zabka as Himself How I Met Your Mother Season 9 Episode 10

After Barney entrusted Ted with protecting a signed Wayne Gretzky photo for Robin, it soon got covered in ink. Switching into Detective Mosby mode, Ted established Zabka as his primary suspect. At first, the Cobra Kai actor produced a seemingly airtight alibi. As Ted and Lily dug deeper, however, they discovered it was a ruse and that Zabka was indeed the culprit. He promptly confessed to the sabotage (or, in Ted's words, "Zabka-tage"), having plotted to frame Ted so he could be Barney's best man again.

At the same time, Zabka recounted what life had been like for him since 1984 — with him booed and pelted with popcorn wherever he goes. When calling his mother, even she booed him and revealed he was often excluded from Thanksgiving. In the end, Ted allowed Zabka to take credit for replacing the photo and saving the day. The move prompted Zabka to riff on his famous final line from The Karate Kid with "You're alright, Mosby".

Season 9, Episode 20, "Daisy"

William Zabka as Himself How I Met Your Mother Season 9, Episode 20

After an argument with Lily, Marshall found himself puzzling over where she'd vanished to for three hours. Furthermore, over breakfast with Ted and Barney, Marshall questioned why she had changed her mind about moving to Italy. Zabka and Ranjit were also present. In fact, it was Zabka that offered Marshall his first clue — revealing that he'd seen Lily outside of a store at 3 am, before getting into a car owned by The Captain (Kyle MacLachlan). Zabka then drove with the gang to back up Marshall in confronting him. He remained present as Detective Mosby resurfaced and incorrectly announced that he'd solved the mystery. Believing that Lily had merely resumed smoking, Ted pulled out a positive pregnancy test rather than a cigarette from the soil of a potted daisy. "You can smoke those?" Zabka humorously asked.

Season 9, Episode 21, "Gary Blauman"

William Zabka as Himself Alyson Hannigan as Lily Aldrin Jason Segel as Marshall Eriksen Josh Radnor as Ted Mosby How I Met Your Mother

During a date with Cristin Milioti's Tracy McConnell (aka The Mother), Ted told her the story of Gary Blauman. After he turned up unexpectedly at the wedding of Barney and Robin, the gang was divided on whether to make room for him or demand that he leave. While Lily was in favor of him staying, Ted and Barney were vehemently against. With Marshall serving as a judge, the three revealed their respective reasons for either loving or hating Blauman — which ranged from narrowly avoided tattoo disasters to the stealing of an accidental curly fry. Zabka, overhearing the name, soon interjected. Joining Lily's side, Zabka revealed that he also loved Blauman.

Related: How I Met Your Mother: Why The Sitcom Ended With Season 9 (Was It Canceled?)

Despite only meeting him ten minutes before, Zabka was moved by the fact Blauman recognized him for his poetry rather than The Karate Kid. The episode would feature some choice references to the film, including Barney threatening to have Zabka crane-kick Blauman in the face. "It's not even my move," Zabka insisted. "If I was gonna do anything, I'd sweep the leg and put you in a body bag. Everyone knows that." The end of the episode revealed that Zabka would go on to win the American Humanities Medal for Literature.

Season 9, Episode 22, "The End Of The Aisle"

William Zabka as Himself Tim Gunn as Himself How I Met Your Mother Season 9 Episode 22

Zabka's final appearance occurred in the episode before HIMYM's polarizing two-part finale. Having overcome their cold feet and respective panic attacks, Barney and Robin finally said, "I do". As they exchanged rings and vows, several recurring guest-stars were glimpsed among the crowd watching. A smiling Zabka was one of them. Seen only for a few seconds, he was seated next to Tim Gunn — who had also played a version of himself. The previous episode had documented the fates of its regular supporting characters. Therefore, the brief glimpse was all that was needed to put a final stamp on the various threads of the wedding storyline.

On the whole, Zabka's arc across the show really lends credence to the idea that How I Met Your Mother directly influenced the creation of The Karate Kid continuation. After all, everything Zabka did was about emerging from the shadow of being seen as a villain. The path is thematic similar to the one Johnny Lawrence would tread years later. Both shows also greatly blend comedic and dramatic elements, serving as equally positive showcases for Zabka's talents. As such, it's easy why fans were since vocal in their desire to see the opposite side of the meta coin — and have Harris play a role on Cobra Kai.

More: Cobra Kai: Why HIMYM's Barney Probably Wouldn't Support Johnny Anymore