The Magician's Code


"The Magician's Code" is the hour-long final episode of the seventh season of the CBS sitcom How I Met Your Mother. It aired in two half-hour parts on May 14, 2012.

Plot

;Part 1
Lily starts going into labor, but refuses to go to the hospital until Marshall is there with her. Ted and Robin try to distract her with stories from their past until her contractions are four minutes apart, and Robin offers to deliver the baby for her, claiming that she has done this before, and Lily finally agrees to go to the hospital.
Meanwhile, Barney and Marshall are stuck in Atlantic City following the events of "Good Crazy" and must find a way back to Manhattan for the birth. Barney offers to help Marshall on the condition that Marshall's son has the middle name "Wait-for-It". Marshall agrees and Barney manages to secure two seats on a bus to New York — only for Marshall to realize that the destination refers to the state of New York and not New York City; its final destination is actually Buffalo. The two are left trying to find another way back to the city when several senior citizens on the bus, inspired by Marshall's predicament, claim to be having heart attacks to force the driver to take a detour to the hospital where Lily is giving birth.
Lily starts giving birth without Marshall, and Robin faints at the sight of the birth and while talking to Ted in the waiting room, expresses confusion since she had not fainted during prior deliveries. Ted reasons that it is different when it is someone she loves, and the conversation leads to them finally reconciling as friends. Marshall arrives just in time for his son to be born, whom Lily names after Marshall's late father and honors Barney's condition, and everyone welcomes Marvin Wait-for-It Eriksen into the world.
;Part 2
Part 2 begins with a flashforward to Barney's wedding, where Lily tells Ted that the bride wants to see him.
After the birth of Marshall and Lily's son, Robin tells Ted that all the women he has pursued in the past were the wrong person, with Victoria being the only exception. She convinces Ted to call Victoria; Ted eventually asks Victoria to meet him at MacLaren's, hoping to find out if she ever got engaged. She arrives in a wedding dress and asks him to run away with her, as she has never stopped thinking about him. After seeking advice from the others, he agrees and gets in the car with her, but Ted admits he cannot let Victoria leave her fiancé at the altar after what Stella did to him. He tells Victoria that he is taking her back to the church so that she can go through with her wedding. However, he begins reminiscing about their past relationship and drives past the church, the two hold hands as they drive off into the sunset together.
Marshall and Lily appoint Robin to take the photograph for baby Marvin's birth announcement, but she is unable to take a decent shot of the family together. Eventually the two fall asleep on their bed with Marvin between them, allowing Robin to get a perfect shot.
Barney returns to Quinn to find that she has re-decorated the apartment bright pink as an act of revenge for his leaving town after their fight, but Barney is glad that she has not left him and the two make up. On the way to Hawaii, Barney is stopped at airport security because of a mysterious box he has placed in his luggage, the contents of which he claims he cannot reveal due to "the Magician's Code". He and Quinn are taken in for questioning, where she reveals that she has quit her job for Barney and is now unemployed. After missing their flight, Quinn is ready to leave, forcing Barney to perform the trick contained within the box, which turns out to contain an engagement ring. He proposes to Quinn and she accepts. They return to Marshall and Lily's apartment to announce their engagement. As Quinn leaves the room to tell the story of the proposal, Barney asks Robin if she is okay with everything. Robin says that she knows how awesome he is, and that she is happy for him.
The episode closes with a flash-forward to Barney's wedding. Ted and Marshall stand in a hallway, with Marshall talking about how everything turned out for them. Ted enters a room where the bride is located, when the bride turns to face Ted, it is revealed to be Robin.

Production

In an interview published after "The Magician's Code" originally aired, show co-creator Craig Thomas admitted that Barney's bride "had to be ", and it was decided, "literally years ago," that the two of them would get married after they originally broke up in season 5. As for Lily and Marshall's baby's middle name, "Wait-for-It", Thomas said, "How often do you tell someone your middle name?... Middle names aren't that useful and why not?".

Reception

The season finale was viewed by 8.49 million viewers.
Donna Bowman of The A.V. Club graded the episode at B, stating that much happened in the episode even if there were contradictions along the way while the outcomes of certain events are attempts at misdirection.
Entertainment Weekly's Michelle Profis stated the episode does not leave anything for the audience to contemplate before the next season but left some emotional moments such as the baby being named after Marshall's father.
Ethan Alter of Television Without Pity gave part one a C+ and part two a C-. He referred to the episode as a "fake clip show" where "the fake clips here were funnier than anything else in the episode", and remarked that the show could have revealed Robin as Barney's bride with equal impact in the season premiere, thereby making the entire season redundant.