It was previously reported that former House actress Jennifer Morrison would appear on the show as a new love interest for Ted (Josh Radnor).
Entertainment Weekly now claims that MacLachlan will play the ex-husband of Morrison's character Zoey in at least two upcoming episodes.
The actor is known for starring in cult drama Twin Peaks and more recently played Orson Hodge on Desperate Housewives.
How I Met Your Mother continues on Mondays at 8/7c on CBS. MacLachlan's first episode is expected to air in early November.