"(I) am quite proud to say that I am a very content gay man living my life to the fullest," Harris tells People magazine's Web site.
The 33-year-old actor said he decided to reveal his sexuality to end "speculation and interest in my private life and relationships."
Harris may be referring to an Oct. 23 item on the Web site Canada.com that claimed he had helped his "longtime sweetheart," actor David Burtka, land a part on his hit CBS sitcom "How I Met Your Mother."
That was followed by an unconfirmed report Nov. 1 that a publicist for Harris said the actor is "not of that persuasion."
Perez Hilton, Defamer.com and other gossip blogs jumped on the topic, eager to "out" the actor.
Hilton, who is openly gay, counts Harris' coming out as a victory. "We are so proud (despite the naysayers) in having a hand in bringing about change," writes the self-defined "Queen Of All Media," using the royal "we."
Harris rose to fame on TV as a teen, playing the namesake doctor on the series "Doogie Howser, M.D."
He plays the womanizing Barney Stinson on the CBS show "How I Met Your Mother."