Lily is in labor and Marshall is very drunk in Atlantic City, but it's impossible to get a cab because of a big thing that Old Ted can't remember.
Ted and Robin arrive and Ted's freaking out, despite shouting that he's "not freaking out!" Robin is confident she can handle the situation because she once helped deliver a horse on the farm in Canada. Ted's more focused on putting out a kick-ass labor announcement email. Lily needs a distraction, so Robin tells her about her worst cab ride ever. Lily has another contraction.
Barney tells Marshall he'll get him to the hospital on time, but in return Barney wants to choose the baby's middle name: "Wait for It." That's the name. So, for example, Barney Wait for It Eriksen. Now Barney and Marshall need to win a motorcycle to get to New York, so they have to play slot machines.
To distract Lily, Ted tells her about Robin's "second base with Neil Young" story. It wasn't Neil Young. Robin then busts out the "Cuban Sandwich Crisis" story, in which she covered for Ted who had an explosive restroom situation at a party and took the fall for it when Barney accused her of causing the awful smell. Lily needs more stories, so she asks for "Where does that door go?" Ted recalls seeing a mysterious door at the bar and walking through it. Then Robin followed.
Lily gets a call from her dad, and she's upset that Ted emailed her dad -- who is the worst person to have around in a medical situation. She recalls when she was a young girl, her dad sitting next to her telling her the awful things that could happen during her tonsil surgery.
In Atlantic City, Barney tries to steal the motorcycle -- unsuccessfully (he's grabbed by security). Marshall, completely wasted, mutters to himself that he's on his way to Lily. But he can't get up two steps that lead toward the casino exit.
Ted tells Lily "The Tale of the Cursed Pants." Marshall is shown wearing purple and green plaid pants and says everything has been going wrong since he got them. He found a note written in Chinese in the pocket, which led him deep into Chinatown -- where a dry cleaner gave him the suit jacket that went with the pants.
Meanwhile, wasted Marshall is trying to get cash from an ATM, which he insists turned into a video game and some Web videos of chimpanzees in a karate fight. Then it spit out his shredded card. Barney shows up and explains that he simply asked the guards, "Can you show me the rule that says you can't drive a motorcycle on the casino floor?" Sure enough, they couldn't. Barney found a bus driver who has two open seats headed back to New York.
Back to the door story Barney follows and walks through.
Lily's contractions are now four minutes apart, and Marshall learns from the bus driver that the bus is headed to Buffalo.
At the hospital, Lily learns she can't have an epidural. Lily needs another story, so Ted tells her about the time Barney tried to pick up girls as the Terminator. Robin tells her about Ted's "freakishly long arm hair." Back to the door story, Lily starts to think she should check out the door, and she goes through. Ted then tells her about the time they tested if banana peels are really slippery, and the time they decided to go as The Breakfast Club on Halloween but failed to coordinate their costumes (they all dressed as Bender). Ted finally tells Lily about the time Lily went into labor, which is happening now. Robin looks under the sheet and tells Lily she's "rock solid" and can see the baby's head. Then she passes out.
Just then, Lily's dad shows up. We see the rest of the story from her tonsil surgery, in which Lily told the nurse she had no idea who her dad was, and he was escorted away by security.
Barney and Marshall try to talk the bus driver into stopping in New York City. The driver says unless there's an emergency he's not allowed to stop the bus. Barney sits down and tells Marshall he did all he could. But then something amazing happened: A bunch of the seniors on the bus stood up and declared they were having heart attacks. Marshall gets to the hospital.
Ted and Robin chat in the waiting room and decide to be friends. "I love you, Robin," Ted says, but he was just kidding. Marshall comes out and announcing he's a dad. Their boy is here: Marvin Wait for It Eriksen.
Finally, back to the door story, Marshall is the last holdout and he slowly approaches. He opens it, only to have Ted, Barney, Robin and Lily inside all shout, "BOO!"
And this brings us to Barney's wedding, where Lily tells Ted the bride wants to see him. "How the hell did we get there?" Old Ted asks.
Back to Marshall and Lily's baby, Ted tells Robin that's what he wants. Robin tells Ted he's "full of crap" because he's always chasing the wrong women. She says if he really wanted a family he'd stop pursuing women he knows he has no future with. He mentions Victoria, and Robin tells him he gave up Victoria so he could chase a "hot piece of ass." That was Robin. She tells him he should call Victoria. The last time he saw Victoria she was engaged, but Robin says that could have ended.
Barney is worried about having left things badly with Quinn. He gets to his apartment and sees that it's been remodeled pink with Hello Kitty dolls. He's just glad she's still there, and hugs her. "Welcome home," she says, and they kiss.
Robin was put in charge of Marvin's birth announcement photo. Ted gets a text from a girl he met on the train and wants advice from Marshall and Lily on what he should do. Marshall and Lily tell him he can only come to them with questions that are of an 8 magnitude or higher.
Ted calls Victoria and asks her if she wants to get together and they make plans to meet at 1:30. Ted originally said 2, but Victoria asked to make it earlier because she might have a thing later.
Ted is ready to look for signs that would indicate whether Victoria is still engaged. Then, she walks into the bar in a wedding dress. "No ring on the finger," he notes.
At the airport on their first trip together, Barney's bag sets off the metal detector and he opens it to reveal a mysterious box. He says it's a magic trick, then reveals that the security dogs are probably barking because of the explosives. The inspectors draw their guns and Barney insists he can't say because a magician never reveals his secret.
Barney then goes into a long story about Mr. Flanagan, the magic teacher he had when he was a teenager, who, it turns out, was banging Barney's mom. Barney tells Quinn he was planning on spending three 14-hour days at a magic show in Honolulu.
After some awkward conversation about coffee, Victoria tells Ted she's never stopped thinking about him. She tells him she's ready to drive off into the sunset with her. Victoria gets up to go to the restroom.
At the airport, Barney can only reveal his trick to another magician and it turns out one of the TSA agents is a magician. Barney whispers the trick to the agent, who thinks it sounds cool.
Ted calls Robin and tells her about Victoria and Robin tells Marshall and Lily about it. At first, it's a 7, but when Robin explains Victoria is in a wedding dress, Marshall declares it a 10. Marshall, Robin and Lily huddle with Ted -- who orders four shots of tequila -- and discuss. Lily thinks it's a bad idea for Ted to take off with Victoria because she's having a freakout she might regret later. Robin thinks it's a good idea. Marshall and Lily do their shots and Robin snaps a picture, reminding the new parents that they wanted a picture of Marvin's first outing. That's when they realize their baby's first outing is at a bar -- and Lily dribbled tequila on Marvin's soft spot.
Victoria emerges and asks Ted if it's happening. He asks her whether FDR or the West Side Highway is the quicker way to the sunset.
Being questioned by TSA, Quinn lists her occupation as "unemployed," then reveals to Barney that she quit for him. She asks Barney to reveal the trick and he says he can't: "Magician's code."
Ted and Victoria are driving, and she suggests that they go on what was going to be her honeymoon. Ted feels bad and says they're going to drive back to her wedding.
He explains to her that he got left at the altar and it nearly killed him. He needs to respect that she's someone's fiancee. So he suggests they find a motel, jam in a quickie and head back to her wedding. Victoria laughs and realizes she needed to hear Ted say that, and now, "sobering up," she wants to pretend this never happened. Ted tells her it never happened.
At the airport, an agent tells Quinn and Barney that their flight left and Quinn is free to leave but Barney needs to be held for further questioning. Barney decides to show them the trick. Barney goes through a whole magician's ritual that includes a sword, an explosion a plant sprouting, which grows a flower holding a diamond ring in it. Barney proposes to Quinn -- loudly.
Robin snaps a perfect picture for Marvin's card -- Marshall and Lily asleep with Marvin laying between them. That's when Barney and Quinn walk in with news of their engagement. Marvin needs a diaper change and Quinn follows Marshall and Lily to the nursery. Barney and Robin joke about having one last chance to head for the door and run off together. It gets serious for a moment and Barney tells Robin he hopes it isn't weird for her. She says she's really happy for him.
Ted, driving with Victoria, blows right past the church. They hold hands and keep driving toward the sunset.
"A little ways down the road" we see Ted and Marshall in tuxedos talking about how the road to this day has had a few twists and turns. But they agree that in a weird way it all makes sense.
Ted finally goes in to see "the bride." It's Robin.