Season 7: Episode 23 - "The Magician's Code Part One"

"The Magician's Code Part One": A drunk Marshall and Barney desperately try to get out of Atlantic City and to the hospital, in order to get back in time before Lily gives birth. Meanwhile, Ted and Robin try to sooth and distract Lily during her painful contractions by telling her funny stories about their group, including the time Robin and Ted were cab-napped by a homeless man, the time Marshall thought his pants were cursed, the time Barney acted like the Terminator to pick up girls and the tale of the mysterious door at McLarens. At the hospital, Lily panics as she goes into labor and Marshall is still not there, but her father, Mickey, shows up to try and comfort her. Finally, Marshall arrives in the nick of time to see the birth of his son.