Kyle MacLachlan Kyle MacLachlan

Kyle MacLachlan is heading to How I Met Your Mother, a rep for the show confirms to TVGuide.com.

How I Met Your Mother's Carter Bays: Season 6 will be our best one yet

The former Desperate Housewives cast member will play The Captain, the ex-husband of Ted's new love interest, Zooey (Jennifer Morrison). Morrison's first episode debuts Oct. 18 and MacLachlan's is schedule to air in early November.

Entertainment Weekly first reported the casting news.