"Doppelgangers" is the 24th and final episode of the fifth season of the CBSsitcomHow I Met Your Mother, and the 112th episode overall. It originally aired on May 24, 2010.
Plot
Although Marshall is ready to have a baby, Lily is not, so they reach a compromise: they make a pact to start trying to have a baby once they finally see Barney's doppelgänger. One day they spot Barney's doppelgänger, who appears in the form of a brown-haired cab driver, but Marshall later finds out it's a ploy by Barney to pick up women from the UN headquarters and sleep with one woman from every country (which does not work). Meanwhile, Ted decides to get his hair dyed blond, much to the amusement of the gang.
Robin finally gets an offer for her dream job as lead anchor at rival station WNKW. However, she decides to give it up as it requires her to move to Chicago and she wants to stay in New York City for the sake of her relationship with Don. Having nearly had to deal with Robin's departure, Barney realizes that the addition of a baby to the gang would not be that bad after all, and dresses up as an Estonian street performer in order to convince Lily that the fifth doppelgänger has appeared. Lily and Marshall see through his act, but thank him for the gesture, assuring him that he will be a part of their family.
Robin is disappointed when Don tells her that he accepted the WNKW job. Heartbroken that Don was not willing to give up the job like she did, Robin breaks up with him and moves back to Ted's apartment. Ted tells her that although they have all been searching for their doppelgängers, things have changed so much in the five years since they first met that the five of them are now, in fact, doppelgängers of their own selves. Ted comforts Robin by saying she has become more courageous and that doppelgänger Robin is 'amazing'. Robin tries to kiss him, but bursts out laughing when she takes off Ted's cap and sees his blond hair again.
Four months later, Lily sees a street vendor selling pretzels who bears an uncanny resemblance to Barney and gathers the rest of the gang to witness the doppelgänger, but they find that the vendor looks nothing like Barney. Just as Barney is about to protest, Marshall stops him. They realize that one only sees what one wants to see, when one wants to see it, and know that Lily is finally ready to have kids.