Marshall and Barney
Marshall and Barney have been friends since 2001. Like with Ted, Barney wanted to teach Marshall how to live meaning he was going to help Marshall sleep with various women as he does. Being loyal to Lily, Marshall refused his offer. Marshall later messes with Barney, by flirting with Lily, who Barney did not know at the time. Barney starts calling Marshall the "King", and even followed him around for a week. Regardless of this, Barney and Marshall became friends and Barney accepted the fact that Marshall was committed to Lily. Throughout the show, Marshall and Barney's friendship has become stronger due to them becoming co-workers and eventually Barney being the one who marries Marshall to Lily. After being caught in the moment of reconciliation between Ted and Barney, Marshall said that he saw both of them as brothers. The two do fight over which one of them is Ted's best friend, which has become a running gag in the show.
From Marshall's perspective, he most likely sees Barney as his second best friend. Although Marshall disapproves of Barney's womanizing ways and dismissed the advice Barney gave to him about women before he and Lily were married, he still loves hearing Barney's dirty jokes. Marshall sees Barney as someone who looks out for him due to Barney helping him get his job when he had financial troubles, helping him fit in at work, and most importantly convincing Lily to leave her art fellowship in San Francisco and come back to New York to get back together with him.
From Barney's perspective, he most likely sees Marshall as his second best friend as well. Although Barney gets annoyed by the corny things Marshall says regarding romance and his relationship with Lily, he has said that Marshall is the best man he knows. Before Marshall married Lily, Barney wanted him to break up with her and be single with him and Ted. Due to Marshall's commitment towards Lily and his desire to help the environment, it's possible that Barney sees Marshall as a younger version of himself, when he wanted to join the Peace Corps and was committed to his college girlfriend, Shannon. Because Shannon broke Barney's heart and cheated on him, Barney may have been trying to protect Marshall from the heartache that he went through. Barney eventually gained an understanding of Marshall that was good enough for him to know that Marshall would never be truly happy without Lily, which is why he kept stealing girls away from him after Lily broke up with him and convinced Lily to come back to New York to get back together with him.
Shortly after Barney met Ted, Barney and Marshall met in 2001. Similar to his initial meeting with Ted, Barney decided to teach Marshall how to live as well after learning that he has only had sex with one woman. Marshall, being committed to Lily, refused his offer. Barney then asked Marshall if his girlfriend was as hot as the redhead that just entered MacLaren's. When Marshall and Ted saw that the woman Barney was talking about was actually Lily, they decided to play a trick on him. The two of them acted out a skit, where Marshall pretended that he wanted have sex with someone new and Ted tried to convince Marshall out of it. Barney, excited that Marshall was taking his advice, gave him a "pep talk" where he told Marshall that he could do this, but most likely he probably can't and that the important thing was that hitting on the hot redhead would boost his confidence. As Marshall left to hit on Lily, Barney laughed and told Ted that Marshall was going to crash and burn. Barney was incredibly surprised and spat out his drink when he saw Marshall make out with Lily. He then told Ted that Marshall was a god among men. Afterwards, Barney followed Marshall around and asked him to teach him how to live instead. Marshall apparently allowed Barney to believe that Lily was some random girl for about a week (he even got Barney to do his laundry).
- Cupcake - Barney gets Marshall an internship and helps him buy a suit.
- Life Among the Gorillas - Barney helps Marshall fit in with his coworkers.
- Milk - Barney conscripts Marshall in a prank war.
- The Scorpion and the Toad - Barney is Marshall's wingman.
- Slap Bet - Marshall and Barney make a slap bet.
- Stuff - Marshall slaps Barney the second time, after Barney puts on a horrible play as revenge on Lily.
- Bachelor Party - Barney tries to take over Marshall's bachelor party. Marshall learns that Barney was responsible for him reuniting with Lily.
- Something Borrowed- Barney marries Marshall to Lily.
- How I Met Everyone Else - The story of how Marshall and Barney met is revealed.
- Slapsgiving - Marshall taunts Barney with a slap.
- The Chain of Screaming - Barney tries to give Marshall advice about work.
- The Goat - Barney confides his bro code violations to Marshall.
- The Best Burger in New York - Barney helps Marshall get a job at GNB.
- Woooo! - Marshall and Barney are excited to have Ted work with them but Barney sabotages Ted. Marshall helps him see his wrong.
- Sorry, Bro - Barney mocks Marshall's pantlessness.
- The Front Porch - Marshall's nightshirt seduces Barney.
- Old King Clancy - Marshall and Barney team up to keep Ted from learning that his project has been scrapped.
- Mosbius Designs - Barney turns to Marshall for advice on Robin. Marshall turns to Barney for advice on job security.
- The Three Days Rule - Marshall and Barney team up to prank Ted.
- The Rough Patch - Marshall joins Ted in trying to break up Barney and Robin
- Slapsgiving 2: Revenge of the Slap - Barney gets slapped the fourth time by Marshall
- Unfinished - Marshall serves as wingman to Barney in the seduction of Ted.
- Canning Randy - Barney tries to help Marshall fire Randy.
- Last Words - Barney and Ted try to make Marshall laugh and cheer him up.
- The Perfect Cocktail - When Marshall becomes Zoey's lawyer in her fight to save the Arcadian, he and Barney start fighting.
- Ducky Tie - Marshall and Lily make a bet with Barney that could force him to wear Marshall's ducky tie.
- Disaster Averted - Barney tries to cut a deal with Marshall and Lily to get out of wearing the Ducky Tie, and gets slapped 3 more times.
- No Pressure - Barney is on a mission to find something private of Marshall and Lily.
- Good Crazy - Barney takes Marshall on a road trip to Atlantic City.
- The Magician's Code - Part One - Barney helps Marshall get back to New York before his son is born.
- Slapsgiving 3: Slappointment in Slapmarra - Marshall delivers the Slap of A Million Exploding Suns to Barney.
- The End of the Aisle - Marshall ends the slap bet with the final slap delivered to Barney.