The end is near for long-running CBS series “How I Met Your Mother” … but is it also the end for Barney and Ted’s friendship?

Fans of the comedy are well aware that Ted has had feelings for Robin from the start. Although we know now that Robin is not “The Mother,” Ted is still not ready to watch her marry one of his best friends.

Previews for the ninth and final season show Lily trying to stop Ted from ruining his relationship with Barney and Robin, but based on the episode 4 synopsis she may not succeed.

In episode 4, “The Broken Code,” Barney learns that Ted still has feelings for Robin … and he does not take the news well. According to the episode description Barney will try to work through his anger with Ted by taking his frustrations out on him during the best man poker game. With Marshall encountering some issues on his journey back for the wedding, he’ll be forced to act as a judge and “help settle their dispute” via Skype.

Thanks to a leaked photo from “The Broken Code,” we know that the poker game will feature a special guest -- Tim Gunn from “Project Runway.” How he gets roped into Barney’s wedding shenanigans remains a mystery, though.

How I Met Your Mother
Tim Gunn of "Project Runway" guest stars in episode 4 of "How I Met Your Mother." CBS/ How I Met Your Mother

As for the ladies of “How I Met Your Mother” -- Lily will discover that she is Robin’s only girlfriend, and Ellen D. Williams will be guest starring as Robin’s arch enemy, Patrice.

“The Broken Code” will air on Monday, Oct. 7 as the “longest wedding weekend” continues. Check out brief episode descriptions for the first three episodes of season 9 below:

Episode 1 – “The Locket”

The gang encounters some problems on the way to Farhampton for Robin and Barney’s wedding. The bride and groom-to-be “come across a startling family discovery,” while Lily must confront Ted over his feelings for Robin. Marshall on the other hand sees something only “that changes the course of his entire journey back east.”

Episode 2 – “Coming Back”

Barney’s brother James reveals that he’s getting divorced, and the news leaves Robin worried about her future husband. Ted will struggle with being alone at a romantic hotel while Marshall desperately tries to make it back in time for the wedding.

Episode 3 – “Last Time In New York”

Lily will attempt to deal with Ted and his decision to leave but becomes frustrated when she discovers a list of things he wants to do before his move to Chicago. Meanwhile Robin and Barney realize “they have very little time together before their relatives arrive for their wedding” and set out to find some private time together.