Lopez will play Anita Appleby, "a no-nonsense author of self-help books that teach women how to train men into relationship machines through the power of denial," the network said in a release. "When Robin tells Anita how Barney acts toward women, she makes it her mission to 'break' him."
The episode is set to air in March.
"We couldn't be more excited about Jennifer Lopez joining us on 'How I Met Your Mother," the show's executive producer and co-creator Carter Bays said in a statement. "We're looking forward to a week of revealing outfits and sexy dance moves the likes of which this show hasn't seen since Regis Philbin guest starred."
The series stars Josh Radnor, Jason Segel, Alyson Hannigan, Neil Patrick Harris and Cobie Smulders.
Ukrainian protestors topple Lenin statue [VIDEO]
'SNL': 'Anchorman 2' cast, One Direction sing 'Afternoon Delight' [VIDEO]